Gacnt
By:
Gacnt

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

January 29, 2016 802 views
Nginx Node.js Ubuntu

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?

1 comment
1 Answer

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

Have another answer? Share your knowledge.