We have an Apache server configured as a reverse proxy for our backend application. Currently, the Apache server overrides error codes (4xx and 5xx) and displays a default error page when an error occurs. This behavior is problematic for our backend developers, as they want to return specific HTTP status codes (e.g., 400 for bad requests) along with custom responses. However, these responses are being overridden by the default proxy response due to the ProxyErrorOverride On
setting in the Apache configuration.
I found that the ProxyErrorOverride directive controls this behavior. However, I would like to know if there is a way to dynamically enable or disable ProxyErrorOverride
based on a specific attribute in the response header returned by the backend server.
For example, if the response from the backend includes a certain header (let's call it X-Bypass-Proxy
), I want Apache to respect the response from the backend and not show the default error page. Conversely, if the header is absent, Apache should continue using the default behavior of displaying the error page.
Is there a way to achieve this using Apache configuration or through a module? Any guidance or examples would be greatly appreciated!