Why does using nginx as a reverse proxy break local links?

Posted by tsvallender on Server Fault See other posts from Server Fault or by tsvallender
Published on 2012-03-14T14:01:13Z Indexed on 2012/10/12 3:39 UTC
Read the original article Hit count: 500

Filed under:
|
|

I've just set up nginx as a reverse proxy, so some sites served from the box are served directly by it and others are forwarded to a Node.js server.

The site being served by Node.js, however, is displayed with no CSS or images, so I assume the links are somehow being broken, but don't know why.

The following is the only file in /etc/nginx/sites-enabled:

server {

    listen   80; ## listen for ipv4
    listen   [::]:80 default ipv6only=on; ## listen for ipv6

    server_name  dev.my.site;

    access_log  /var/log/nginx/localhost.access.log;

    location / {
            root   /var/www;
            index  index.html index.htm;
    }

    location /myNodeSite {
            proxy_pass http://127.0.0.1:8080/;
            proxy_redirect off;
            proxy_set_header Host $host;
    }
}

I had thought perhaps it was trying to find them in /var/www due to the first entry, but removing that doesn't seem to help.

© Server Fault or respective owner

Related posts about nginx

Related posts about reverse-proxy