Continuing the discussion from Failover API handling:
I want to set up a custom 503 page, so that if my app goes down for any reason, clients are automatically redirected to this custom “Sorry, our service is down” page.
It seems there are two half-solutions:
- I set up healthchecks, and when they fail, Kong responds with a 503. This is the behaviour I’m looking for, but I want to redirect to a custom page instead of just returning a generic “Service Unavailable” response.
- I use the scheme described by Tieske in the linked thread. If I understand this right, it has the desired failure behaviour, but also will send clients to the failure page some small fraction of the time when the backend is healthy. This seems hacky.
Serverless function plugins can’t seem to do this, since they only read the request, not the response, so it can’t tell what the response code is.
I was thinking maybe the “Route-by-Header” plugin might help if I could conditionally inject a custom header when the service was down, but I can’t think of any way to do that within Kong.
Is there no way to do this nicely? I would have thought this is a common thing to want to do. I’ve found several questions in various places about this general idea, but none seemed to be resolved.