The “subfolder issue,” also known as “why can’t I reverse proxy my app into a subfolder?”

I hate the word no. The more i hear it, the worst it gets. This has been a bugbear of ours for years. Why can’t users use to map a subdirectory to an external site hosted elsewhere? As stated in a Reddit post we are firm believers that everything is possible and the limitation exists purely within current structures. So change the structures and systems to fit right. Well, where not sure it’s that simple of a fix.

Have you ever tried to an app into its own name subfolder?

Using for one app, for another. If you’re coming here from one of the self-hosted communities, you might be thinking along the lines of etc.

You’ve probably tried some variations on the following: {
  redir /donarr /donarr/
  handle_path /donarr/* {
    reverse_proxy localhost:8989

But then disaster strikes, and you get a page that is horribly formatted! Perhaps the links are broken. Perhaps you are simply redirected to a blank page. Images, style sheets, and scripts are all broken. If you’re having trouble with this problem, keep reading!

What is the problem?

Firstly, know that this isn’t something unique to HostRooster.

Every reverse proxy server you can think of will have this problem (unless they have some seriously advanced logic built in to deal with it!). This is due to the fact that this is a logical issue rather than a bug or issue with the app itself.

Almost all HTTP applications are written with the expectation of serving requests from the web root.

A request to

would be a request for the web root – this simply means the top of the path hierarchy, the first path element, i.e. not a subfolder.

When you request a website, you will typically receive an HTML document in response. The HTML instructs your browser to access additional elements; static assets such as images, style sheets, and scripts that it will use to further render the web page. Because it assumes it has the web root, it may provide your browser with links like

 /images/stock.jpg and /css/site.css. When you open your browser and access your application directly, that’s fine.

However, if we insert a reverse proxy in the middle and place it in a subfolder, we may encounter a problem. Your application is being proxied from /foo/. When you send the request to HostRooster, and you’re browsing to, you get a HTML document just like before. But the document still has links to /images/stock.jpg and /css/site.css. Your browser follows those links and makes those requests to HostRooster. But HostRooster doesn’t know how to handle requests for /images/ or /css/! You’ve only configured the reverse proxy for /foo/. And now our asset links are broken and the page is, too.

Redirects are another problem, as well. They don’t happen in HTML, usually; they happen in HTTP headers (specifically, Location). These, too, are unlikely to properly reference the subfolder you want.

Solve the problem

To resolve this issue, all links and redirects must point to valid URLs that HostRooster can handle. Something has to give; either the HTTP application’s URLs must be corrected to include the desired subfolder, or Caddy must be configured to allow the app to have the web root it desires.


Welcome to the world of DomainRooster, where roosters (and hens) rule the roost! We're a one-stop shop for all your entrepreneurial needs, bringing together domain names and website hosting, and all the tools you need to bring your ideas to life. With our help, you'll soar to new heights and hatch great success. Think of us as your trusty sidekick, always there to lend a wing and help you navigate the sometimes-complex world of domain names and web hosting. Our team of roosters are experts in their fields and are always on hand to answer any questions and provide guidance. So why wait? Sign up today and join the ranks of the world's greatest entrepreneurs. With DomainRooster, the sky's the limit! And remember, as the saying goes, "Successful people do what unsuccessful people are not willing to do." So don't be afraid to take that leap of faith - DomainRooster is here to help you reach for the stars. Caw on!