RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1368470 - httpd/mod_proxy prepends error page for HEAD request to a next response for next GET request
Summary: httpd/mod_proxy prepends error page for HEAD request to a next response for n...
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: httpd
Version: 6.9
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Luboš Uhliarik
QA Contact: BaseOS QE - Apps
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-08-19 13:33 UTC by Masafumi Miura
Modified: 2019-11-14 08:58 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-08-15 19:47:31 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Masafumi Miura 2016-08-19 13:33:57 UTC
### 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;
~~~


Note You need to log in before you can comment on or make changes to this bug.