I have the following configuration:
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://localhost:3000; # this is where our node js app runs at
proxy_set_header Host $http_host;
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
}
Which proxies [SERVER_IP]/
to localhost:3000
so that it basically routes everything to the node js app.
I then went ahead and wrote another nodejs app, which runs on port 5000
, instead of 3000
:
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://localhost:3000; # this is where our node js app runs at
proxy_set_header Host $http_host;
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
}
location /testing {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://localhost:5000; # this is where our node js app runs at
proxy_set_header Host $http_host;
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
}
However if I go to [SERVER_IP]/testing
it routes it as /testing to my first app which then generates the Express JS message: "Cannot GET /testing".
I changed the order, restarted nginx without problems. Any idea why it would not work? I assume nginx is the first instance before it gets routed to Node JS.
If I change the port of the location / { ... }
I can get the second app, but I would want to run them parallel to each other.
Thanks