https://issues.apache.org/bugzilla/show_bug.cgi?id=52766
Bug #: 52766
Summary: mod_proxy_html connection dropped when back end
redirects with headers only
Product: Apache httpd-2
Version: 2.4.1
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: mod_proxy
AssignedTo: [email protected]
ReportedBy: [email protected]
Classification: Unclassified
Hello,
When a target web site being connected to through a proxy server has a rewrite
with no content in the body, the proxy server closes the connection before
sending any headers. In my case, I can't control the target site and have to
rely on the proxy server to gracefully handle a redirect like this.
An example can be seen with this bit of php code on the target site that the
proxy server proxies to. Put this into the document root as index.php so that
a GET request for / will execute it:
<?php
header ('Location: http://mytargethost.com/test.html');
?>
Connecting directly to mytargethost.com will return headers with no body
content, which is the expected behavior when connecting through the proxy
server:
telnet mytargethost.com 80
Trying 192.168.1.2...
Connected to mytargethost.com (192.168.1.2).
Escape character is '^]'.
GET / HTTP/1.0
User-Agent: Wget/1.11.4 Red Hat modified
Accept: */*
Host: mytargethost.com
HTTP/1.1 302 Moved Temporarily
Date: Sat, 25 Feb 2012 03:47:08 GMT
Server: Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8q DAV/2
mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
Location: http://mytargethost.com/test.html
Content-Length: 0
Connection: close
Content-Type: text/html
But the proxy server drops the connection before sending any headers:
$ telnet myproxyhost.com 80
Trying 192.168.1.1...
Connected to myproxyhost.com (192.168.1.1).
Escape character is '^]'.
GET /mytargethost.com/ HTTP/1.0
User-Agent: Wget/1.11.4 Red Hat modified
Accept: */*
Host: myproxyhost.com
Connection closed by foreign host.
Here is the relevant Apache configuration on the proxy server:
ProxyHTMLEnable On
ProxyHTMLLinks a href
ProxyPass /mytargethost.com http://mytargethost.com
<Location /mytargethost.com/>
ProxyHTMLURLMap / /mytargethost.com/
</Location>
This patch fixed the problem for me on httpd 2.4.1:
--- mod_proxy_html.c 2012-02-24 17:45:53.000000000 -0600
+++ mod_proxy_html-patched.c 2012-02-24 17:51:53.000000000 -0600
@@ -947,6 +947,10 @@
}
}
/*ap_fflush(ctxt->f->next, ctxt->bb); // uncomment for debug */
+
+ if ( ctxt->parser == NULL ) /*If no processing was done,
simply pass the brigade.*/
+ return ap_pass_brigade(f->next, bb) ;
+
apr_brigade_cleanup(bb);
return APR_SUCCESS;
}
Best regards,
Mike Streeter
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]