Mailing List Archive

[Bug 8184] New: - Intermittent "Bad Gateway" on proxied requests.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=8184>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=8184

Intermittent "Bad Gateway" on proxied requests.

Summary: Intermittent "Bad Gateway" on proxied requests.
Product: Apache httpd-2.0
Version: 2.0.35
Platform: PC
OS/Version: Linux
Status: NEW
Severity: Normal
Priority: Other
Component: mod_proxy
AssignedTo: bugs@httpd.apache.org
ReportedBy: rthomas-contrib@liveintellect.org


Error occurs with Apache 2.0.35 configured with rewrite rules that use the [P]
option to proxy requests to Tomcat 4.0.x as follows:

ProxyPassReverse / http://localhost:8080/
RewriteRule ^/(.*)/(.*\.(jsp|serv))\?(.*) http://localhost:8080/$1/$2?$3
[P,skip=2]
RewriteRule ^/(.*)/(.*\.(jsp|serv))$ http://localhost:8080/$1/$2 [P,skip=1]
RewriteRule ^/(.*)/(j_security_check)(.*) http://localhost:8080/$1/$2$3 [P]

The error reported to the browser is:
Bad Gateway!
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request <EM><A
HREF="/mywebapp/main.serv">GET&nbsp;/mywebapp/main.serv</A></EM>.<P> Reason:
<STRONG>Error reading from remote server</STRONG>
If you think this is a server error, please contact the webmaster
Error 502

The error that appears in the error log is:
[Tue Apr 16 21:30:55 2002] [error] [client 192.168.0.7] proxy: Error reading
from remote server returned by /mywebapp/main.serv, referer:
http://tomcatsrvr01/mywebapp/index.html

The error only occurs intermittently (every 3rd or 4th request on average). It
behaves as if requests are being distributed (via round-robin or the like) and
handled sometimes by a worker thread that is not properly initialized for
proxy/rewrite (and sometimes by one that is).

By comparison, Apache v 1.3.24 works perfectly and reliably with the same
configuration in the same environment (actually without changing anything else
and running 1.3.24 instead of 2.0.35 on the very same machine).

Also tried a proxy to another machine running Tomcat 4.0.1 but the error still
occurred with the same frequency.

Also tried proxy to Apache webserver 1.3.x running on another machine but got
no failures that way (so perhaps this is some sort of incompatibility between
Tomcat 4 and Apache 2).