I'm trying to use nginx as a proxy for
this nodejs app. What I've done so far is running the nodejs app with
npm --start on
localhost:2791 with a
bs-config.json which looks like this:
Code:
{
"port": 2791,
"server": {
"baseDir": "src",
"routes": {
"/node_modules": "node_modules"
}
}
}
As for my nginx configuration it looks like this:
Code:
server {
listen 80;
server_name demo.example.com;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location /angular {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header HOST $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:2791;
proxy_redirect off;
}
}
When I access to
demo.example.com/angular I get a:
Code:
[1] 17.06.10 18:35:51 304 GET /index.html
Which is great so far but this same page depends on other js files and when it tries to open them it can't find them so I get errors such as:
Code:
[error] 18#18: *1 open() "/etc/nginx/html/node_modules/dc/dc.css" failed (2: No such file or directory), client: 81.64.208.179, server: demo.example.com, request: "GET /node_modules/dc/dc.css HTTP/1.1", host: "demo.example.com", referrer: "http://demo.example.com/angular/"
[error] 18#18: *3 open() "/etc/nginx/html/node_modules/core-js/client/shim.min.js" failed (2: No such file or directory), client: 81.64.208.179, server: demo.example.com, request: "GET /node_modules/core-js/client/shim.min.js HTTP/1.1", host: "demo.example.com", referrer: "http://demo.example.com/angular/"
[error] 21#21: *4 open() "/etc/nginx/html/browser-sync/browser-sync-client.js" failed (2: No such file or directory), client: 81.64.208.179, server: demo.example.com, request: "GET /browser-sync/browser-sync-client.js?v=2.18.8 HTTP/1.1", host: "demo.example.com", referrer: "http://demo.example.com/angular/"
How can I tell nginx, instead of trying to find the files in /etc/nginx/html to pass the requests to the node app running on 127.0.0.1:2791? I tried to add
root /home/user/quickstart_ng2d3/src in my config file but it didn't work as the sources/dependencies are spread into multiples folders of the project and are linked together with the help of the node configuration files. Thanks for your help!