I'm using nginx as proxy server for my project. In case my app is offline for maintenance I'd like to show a fallback page. This works fine so far. The only problem is, that the server response with a 502 error code - which makes sense. How do I change it to a 503 route in my fallback though?
server {
listen 80;
error_page 500 502 503 504 @fallback;
location / {
proxy_pass http://0.0.0.0:3000;
}
location @fallback {
// I need this to answer with a status of 503 instead of a 502
root /srv/my-project/static;
try_files /fallback.html;
}
}
you can set a error page nginx error page
and set somethig like
error_page 502 =503 /maintenance.html
or something like
location / {
error_page 502 =503 /maintenance.html;
include proxy_params;
proxy_pass http://unix:/var/run/my.sock;
}
location /maintenance.html {
return 503;
}
source : How can I make Nginx return HTTP 503 when my proxied app server is down?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With