'Changing status code from 502 to 503 in fallback route
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;
}
}
Solution 1:[1]
Thanks @shalbafzadeh for that answer, that solved it for me.
In my very particular situation the solution looks like this:
server {
listen 80;
error_page 502 =503 @fallback; <-- THIS
location / {
proxy_pass http://0.0.0.0:3000;
}
location @fallback {
root /srv/my-project/static;
try_files /fallback.html;
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Seltsam |
