I am trying to put a node.js app (node-red) using a reverse proxy.
server {
listen 80;
server_name example.com
location / {
proxy_pass http://example.com:1880;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
This one worked as expected, I could access node-red from example.com
Then I need to use the root example.com
for a homepage, and move node-red into a subfloder.
server {
listen 80;
server_name example.com
location / {
root /home/admin/nginx/www;
index index.html;
}
location /nodered/ {
proxy_pass http://example.com:1880;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
For this attempt, I could access the homepage (index.html) when accessing example.com
, but when accessing example.com/node-red
I got Bad Gateway error
I also tried to change location /nodered/
into location /nodered(/.*)$
following this answer, but then I got 404 error
.
Can anybody help? thanks.