Project

General

Profile

[Solved] Handling mod_proxy 503 errors

Added by daoxakh 4 months ago

I've set up a reverse proxy to another server that isn't always available. When the server isn't available I'd like to display a custom page rather than the normal 503 error page. The configuration I'm trying is:

server.error-intercept = "enable" 
server.error-handler = "/error/error.php" 

proxy.server = ( "" => ( ( "host" => "192.168.0.112" ) ) )

This is working for static requests that result in errors but doesn't seem to be affecting mod_proxy. I realize server.error-handler normally only affects static requests but I had expected enabling error-intercept to make it apply in this case.

I'm using lighttpd/1.4.69 on Linux (Raspberry Pi OS).

Thanks for you help.


Replies (3)

RE: Handling mod_proxy 503 errors - Added by gstrauss 4 months ago

This sounds to me to be a case of hoping the server will "do what I mean" instead of "what I configured it to do". lighttpd does what you have configured lighttpd to do.

server.error-handler = "/error/error.php" handles errors "like" a request to /error/error.php

So how have you configured lighttpd to handle /error/error.php? Is /error/error.php handled by your reverse proxy proxy.server = ( "" => ( ( "host" => "192.168.0.112" ) ) ) which it looks like you have configured to handle all requests? (including requests for static files)

As that is all you have shared from your config, that is all I have to work with. If you would like a different answer, then please read How to get support

RE: Handling mod_proxy 503 errors - Added by daoxakh 4 months ago

No other answer required, that's exactly what I was doing wrong. Thank you for your (very quick) help.

RE: [Solved] Handling mod_proxy 503 errors - Added by gstrauss 4 months ago

BTW, you could server.errorfile-prefix = "/error/" and put static pages under your local document root, even though you have configured proxy.server to forward all client requests. This should work since a 503 error generated by lighttpd not able to contact the backend is internal to lighttpd, not a 503 error response generated by the backend and parsed by lighttpd. Therefore, you do not need server.error-intercept = "enabled", either.

Another option for static or dynamic responses if you are a little bit adventurous: you can use lighttpd mod_magnet magnet.attract-response-start-to = (...) pointing to a custom lua script which checks for and replaces the response body for 503.

There are even more options using other modules, but I am not going to list all the possibilities.

    (1-3/3)