Question

How come my reverse proxy subdir won't work for static content?

I have setup a reverse proxy as instructed in your guys’ tutorial on using a reverse proxy with node and nginx like so:

server {
        listen 80;
        server_name localhost;

        location / {
                proxy_pass http://127.0.0.1:3000;
                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;
        }
        location /forums {
                proxy_pass http://localhost:4567;
                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;
        }
}

Everything works on /

But when I try to go to /forums I get the page to load, but all the static content 404’s because its trying to load it from localhost/w.e instead of localhost/forums/w.e how might I fix this?

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

This question was answered by @asb:

What forum software are you running? Besides configuring it in Nginx, you will also likely need to let the forum app know what it’s base url should be. For instance, with NodeBB you would need to update the url value in you config.json to include the sub-folder in the path. See:

https://docs.nodebb.org/en/latest/configuring/config.html

View the original comment