503 redirect

Francis Daly francis at daoine.org
Tue Jan 25 13:58:43 UTC 2022


On Mon, Jan 24, 2022 at 04:57:02PM +0000, tony tabone wrote:

Hi there,

> I am currently trying to implement a 503 reply with specific pages. I basically have a nginx config which is using GEOIP.
> 
> All the html files load fine with a 200 reply, however I am trying to change the reply to 503 and still show the same page.
> 
> Is it possible for this to be done ?

I think I don't fully understand what your plan for request / response is;
but the usual way in nginx to set a "custom" response body for non-200
http responses is to use error_page: http://nginx.org/r/error_page.

Something like

    error_page 503 /5xx_errors.html;

and then a "return 503;" or equivalent, might work for you?

If you have an enumerated set of uri:s that you want to return different
content to, then it might be possible to have a set of "location
=" locations, each of which sets an error_page and an appropriate
return. That might get a bit fiddly; if you can give a list of "for *this*
request I want *this* response" pairs, it might be possible to come up
with a better suggestion.

Cheers,

	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list