3

We are using an Apache httpd as reverse proxy. In special cases when an error occurs in the backend system, it returns a special header like X-Error=1 (besides the status code 500).

Is it somehow possible to redirect those repsonses based on the presence of named response header? Redirect to a static error page for example. Unfortunately it is not possible to return a status code different from 500, which would solve described problem.

1

1 Answer 1

0

Apologies as this answer is somewhat speculative. I think this will be quite difficult to achieve, but here are some possible solutions.

  1. You could write your own HTTP handler in mod_lua or similar.
  2. You could write an external filter, using mod_external_filter to find the header and then change the response appropriately. This is essentially a "poor mans" version of writing your own handler.
  3. You might be able use ProxyErrorOverride to change the page Apache displays when its gets a 500 response from the backend. If you set it to a CGI local to Apache, you could test for the presence of the header and display the response you wish, otherwise display a default response.

In theory, these all do the same thing. Capture the response before it is sent back to the client and then modify it as necessary.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .