I am trying to build a proxy for my node application through nginx thinking this will give me error pages if the node application failed or is not available on the port.
The node app runs on 127.0.0.1:1337
and I am listening to mydomain:8080
and forward it.
server {
listen 8080;
server_name mydomain;
access_log /log/path/logging.log;
root /path/to/root/;
error_page 400 401 402 403 404 500 501 502 503 504 /error/index.html;
location / {
proxy_redirect off;
proxy_pass_header Server;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Scheme $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_connect_timeout 5;
proxy_read_timeout 240;
proxy_intercept_errors on;
proxy_pass http://127.0.0.1:1337;
}
}
Unfortunately it gives my a 502 bad gateway when I turn off the node app and request mydomain:8080
.
This is the expected behaviour from nginx though. What I want is a page I can define that will display when the service of the node app is down.
Any ideas what how to do that?