Tuesday 16 May 2017

Nginx proxy pass to Nodejs app - Static Content not found

I am trying to proxy pass a path on my server to a node.js app. The problem is the proxy pass works but static content is does not have the new path on it. For example example.com/myapp/ works but static content loses the /myapp/ path (example.com/css/ instead of example.com/myapp/css/ ) and returns 404.

myapp.conf

server {
    access_log /var/log/nginx/avalanche.log;
    root /path/to/my/app;

    location /myapp/ {
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_set_header X-NginX-Proxy true;

      proxy_pass http://127.0.0.1:3000/;
      proxy_redirect off;   
    }
}

The app works when location is / but not with the extra path.



via chaptuck

No comments:

Post a Comment