Bug 1368470
| Summary: | httpd/mod_proxy prepends error page for HEAD request to a next response for next GET request | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 6 | Reporter: | Masafumi Miura <mmiura> | 
| Component: | httpd | Assignee: | Luboš Uhliarik <luhliari> | 
| Status: | CLOSED WONTFIX | QA Contact: | BaseOS QE - Apps <qe-baseos-apps> | 
| Severity: | unspecified | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 6.9 | CC: | cww, luhliari, mmiura | 
| Target Milestone: | rc | ||
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | If docs needed, set a value | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2017-08-15 19:47:31 UTC | Type: | Bug | 
| Regression: | --- | Mount Type: | --- | 
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
### Description of problem: When Apache httpd/mod_proxy is configured with "ProxyErrorOverride On" and ErrorDocument is located on the backend server, httpd/mod_proxy prepends an error page body for HEAD request to a next response for next GET request. ### Version-Release number of selected component (if applicable): httpd-2.2.15-54.el6_8.x86_64 ### How reproducible: Anytime ### Steps to reproduce 0. Put two pages on the backend server: * /example/index.html <html> <h1>/example/index.html</h1> </html> * /error/404_not_found.html (for custom error page) <html> <h1>404 Not Found! - 404_not_found.html</h1> </html> 1. Configure mod_proxy with the following config: ProxyPass / http://127.0.0.1:8080/ ProxyErrorOverride On ErrorDocument 404 /error/404_not_found.html 2. Send a HEAD request to non-existent page to get 404 curl -I -v http://localhost/nonexistentpage 3. Send a normal GET request to an existing page curl -v http://localhost/example/index.html 4. You will see a error page content on the top of response Notes: * Although "ProxyErrorOverride On" is specfied, "/error/404_not_found.html" specified in "ErrorDocument" is not located on the local machine (inside apache httpd) but located on the backend server. * Make sure that you configure ProxyPass to cover path for error page because this issue occurs only when error page is proxied to the backend server. You can use "ProxyPass / ..." or "ProxyPassMatch ^/.*$ ..." to reproduce easily. * The issue happens when same apache child process handle the two requests (HEAD for 404 response and GET for 200 response). You may need to send multiple requests to hit the same child process. ### Actual results: An error page content "<html><h1>404 Not Found! - 404_not_found.html</h1></html>" will be shown at the top of the response. For example: ~~~ $ curl -v http://localhost/example/index.html > GET /example/index.html HTTP/1.1 > User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.19.1 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2 > Host: localhost > Accept: */* > < HTTP/1.1 200 OK < Date: Fri, 19 Aug 2016 13:17:53 GMT < Connection: close < Transfer-Encoding: chunked < Content-Type: text/html; charset=UTF-8 < <html><h1>404 Not Found! - 404_not_found.html</h1> </html> HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Accept-Ranges: bytes ETag: W/"45-1471612521000" Last-Modified: Fri, 19 Aug 2016 13:15:21 GMT Content-Type: text/html Content-Length: 45 Date: Fri, 19 Aug 2016 13:17:53 GMT <html> <h1>/example/index.html</h1> </html> ~~~ ### Expected results: Get only an actual response of /example/index.html only without an error page content for the last HEAD request. ### Additional info: A patch proposed by the customer (NTT OSSC) is adding the followings in ap_die(): * modules/http/http_request.c ~~~ @@ -196,7 +196,11 @@ "error-notes")) != NULL) { apr_table_setn(r->subprocess_env, "ERROR_NOTES", error_notes); } + if(r->header_only){ + r->method = apr_pstrdup(r->pool, "HEAD"); + }else{ r->method = apr_pstrdup(r->pool, "GET"); + } r->method_number = M_GET; ap_internal_redirect(custom_response, r); return; ~~~