Answer the question
In order to leave comments, you need to log in
Redirect if NodeJS application is not running?
Is it possible to configure Nginx to redirect the site visitor to some other address if the NodeJS application is not currently running? If yes, then so?
I don't want users to see a blank page with a 502 Bad Gateway error while I'm doing something with the server.
Here is an excerpt from my virtual host settings. I suspect some changes need to be made. Or not?
root /var/www/site/public;
index index.html;
location / {
try_files $uri @backend;
}
location @backend {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto https;
proxy_cache_bypass $http_upgrade;
}
Answer the question
In order to leave comments, you need to log in
I have never worked with nginx, but judging by the documentation and other examples on the same page, if you search for the phrase error_page , something like this should work:
...
index index.html;
error_page 502 https://example.com/;
error_page 404 /404.html;
location / {
try_files $uri @backend;
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question