Search code examples
apachemod-proxy

mod_proxy ProxyErrorOverride On always discards response body


I am having an issue that may be just a fundamental misunderstanding of how this feature works but wanted to ask nonetheless. I am trying to enable the ProxyErrorOverride directive from the proxy module while using two reverse proxies (one at the root and one at /api). We would like to be able to return Custom ErrorPages (via the ErrorDocument directive) for a range of 4xx and 5xx status codes. There are however status codes that we want to be able to pass through to our web applications as errors that are being explicitly sent from the API.

At this current moment whenever I turn on the ProxyErrorOverride directive we do see certain status codes being routed to our generic error page, but the status codes that we try to pass through (by not declaring the ErrorDocument directive) seem to be coming back with the right status code (for example: 418) but using a generic apache response body that says something along the lines of "418 Unknown reason contact your admin@domain.com..blah blah".

Is there any way to tell Apache that I want to retain the response body through the proxy or is it always discarded by Apache?

For some context I am using the official 2.4.33 httpd docker base and am able to reproduce this behavior with even the most basic Apache configuration. I tried stepping through some of the source code (I don't write a lot of C) and from what I could tell it seemed that discarding the response body was perhaps the default behavior and that the only override was a custom response.

Would love some clarification on this. Is it possible to pass through error messages with the ProxyErrorOverride directive set to On?

I saw this post: Make apache mod_proxy ProxyErrorOverride include original page contents with mod_include

which also seems to imply that ONLY SSI Responses can be served with ProxyErrorOverride On is there any documentation or sources that can be cited that confirm this? Any Apache based workarounds?


Solution

  • From my understanding ProxyErrorOverride overrides any of the responses received from the origin above 400.

    Can't exclude specific ones.