Bug 47106 - Proxying of ErrorDocument path overwrites HTTP Status
Summary: Proxying of ErrorDocument path overwrites HTTP Status
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_proxy (show other bugs)
Version: 2.2.11
Hardware: All Mac OS X 10.4
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2009-04-27 09:18 UTC by Ross Heritage
Modified: 2010-02-13 20:28 UTC (History)
0 users



Attachments
Fix for the problem (5.29 KB, patch)
2010-02-12 16:25 UTC, Graham Leggett
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ross Heritage 2009-04-27 09:18:18 UTC
I have a slightly unusual setup where all content is retrieved via mod_proxy from various servers. However, to more clearly demonstrate the issue, I can simplify things to this configuration:

ProxyErrorOverride On
ErrorDocument 404 /404error.html

RewriteEngine On
RewriteRule (.*) http://backend.sever$1 [P]


When requesting /whatever from this server, the initial request goes through to 'backend.server', which issues a 404 error.
 
The frontend server then makes another request to 'backend.server' for '/404error.html'. backend.server has this file, so responds with an HTTP 200 response.

The headend server now responds to the original request to /whatever, returning a HTTP 200 with the HTML for the error document.
Comment 1 Graham Leggett 2010-02-12 11:59:36 UTC
Comparing the default_handler to the proxy_handler, the default_handler is respecting and not touching the r->status == 404 that is passed into the subrequest.

In contrast in the proxy, proxy_run_scheme_handler() stomps on r->status, replacing the 404 with the 200 it got from the backend.

Looks like the fix is to teach mod_proxy not to do that.
Comment 2 Graham Leggett 2010-02-12 16:25:31 UTC
Created attachment 24976 [details]
Fix for the problem

The proxy_handler was overwriting r->status with the response code from the backend, which was then faithfully passed to the frontend. This patch works out when the original value should be maintained and passed to the client.
Comment 3 Graham Leggett 2010-02-13 20:28:16 UTC
Fixed in r909899, proposed for backport to v2.2.