I am using HAproxy in front of an app that is on multiple other servers. I would like to set up a vhost in a local nginx instance that only serves a 503 for every request (to use as the 'backup' server when all backends are down). I know how to set the custom error page (as in How can I make Nginx return HTTP 503 when my proxied app server is down?) but how I can make it so that every request to nginx returns a 503?
Asked
Active
Viewed 1.1k times
1 Answers
19
This doesn't work?
location / {
return 503;
}
There might be some tricks you have to use to get assets to show up on your custom error page (i.e., say your 503.html has an image in it. You have to do some logic to make the image show up with a 200 code, otherwise it'll be missing with a 503).
cjc
- 24,533
- 2
- 49
- 69
-
In my case, for an endpoint server, just returning the 503 was sufficient. Thanks! – Chris Prince May 21 '21 at 14:21