Setup Nginx Reverse Proxy for Docker app on Domain Subfolder


I’ve been struggling to get my Nginx Reverse Proxy to work for a Docker app. Similar questions have been asked but haven’t provided the solution for this situation. I’ve spent hours now trying to get this working.

  • I’m trying to self host Plausible which runs in a Docker container at http://localhost:8000
  • Going to http://server-ip:8000/ works fine

I want to set up a Nginx reverse proxy to provide SSL + and set it up on my domain. The tricky part is that I want to serve it from a subfolder instead of the root.

So serving it from instead of

Current Code:

location /plausible {
        rewrite ^/plausible/?(.*) /$1 break;
        proxy_pass http://localhost:8000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;

The Problem

  • redirects to instead of
  • If I manually go to I can see the form field but all the styling and scripts are broken. They try to load from instead of

So I believe the Docker app expects to be on the root URL. So Nginx should rewrite the requests to include the subfolder in some way? I just can’t figure out how to do it.

What I’ve tried:

  • Trailing slash, no trailing slash
  • Just proxy_pass
  • All kinds of rewrite variations

Anyone who can help me in the right direction? Thank you in advance

Source: Docker Questions

Categorised as docker, nginx, nginx-reverse-proxy, subdomain Tagged , , ,


Leave a Reply

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us