21

I get this error every few minutes when using mod_proxy as a reverse proxy to a SOAP web service. There's probably 3 or 4 requests going per seconds so we're talking around 1 or 2 out of every thousand that have this error.

[Tue Nov 23 11:44:14 2010] [error] [client 172.16.1.31] (20014)Internal error: proxy: error reading status line from remote server soap1.server:8888
[Tue Nov 23 11:44:14 2010] [error] [client 172.16.1.31] proxy: Error reading from remote server returned by /someapp/path/to/web/service

This causes the request to fail. If I have the client connect directly to the soap server without using the proxy, success is 100% so the problem appears to be in the proxy

The configuration looks like this. The purpose is to switch to a backup server if the primary one is unavailable:

<Proxy balancer://apicluster>  
BalancerMember http://soap1.server:8888 lbset=0 
BalancerMember http://soap2.server:8888 lbset=1 
</Proxy>  

ProxyPass /someapp balancer://apicluster/someapp 
ProxyPassReverse / balancer://apicluster/someapp 

Has anyone run into this and found a fix? There's some mentions in bug reports but no solutions. The only thing that may be unusual is the client request could be 100MB or larger, so the request could take a little longer than you'd expect for a SOAP call.

JOTN
  • 1,727
  • 1
  • 10
  • 12

3 Answers3

28

In case someone else runs into this. This is a bug in mod_proxy that can be avoided by putting these lines in your httpd.conf:

SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1

https://issues.apache.org/bugzilla/show_bug.cgi?id=37770

For info on what these variables do see the mod_proxy documentation. They have a specific section, Protocol Adjustment, that addresses these variables.

Breedly
  • 230
  • 2
  • 8
JOTN
  • 1,727
  • 1
  • 10
  • 12
  • Depending on your installation, the `httpd.conf` file might be in the following locations ([source](https://www.phusionpassenger.com/library/install/apache/working_with_the_apache_config_file.html#the-location-of-the-apache-configuration-file)): - `/etc/apache2/httpd.conf` - `/etc/apache2/apache2.conf` - `/etc/httpd/httpd.conf` - `/etc/httpd/conf/httpd.conf` – chris Jun 18 '20 at 16:03
5

Take note of the Apache documentation here: http://httpd.apache.org/docs/2.2/mod/mod_proxy_http.html

It seems there is a race condition in mod_proxy_http, but it can be avoided by including:

SetEnv proxy-initial-not-pooled 1

Which prevents Apache using a pooled connection if this is an initial request.

The document does note that this setting will give a performance downgrade.

David Purdue
  • 51
  • 1
  • 2
  • 1
    `proxy-initial-not-pooled` is only effective if you have a specific patch, which I believe is not a part of httpd 2.2. I don't know about httpd 2.4. See https://bz.apache.org/bugzilla/show_bug.cgi?id=37770#c88 – kubanczyk May 11 '16 at 14:01
0

You can also suppress this related error message (AH01102: error reading status line from remote server) by using the apache module mod_reqtimeout and this conf directive:

RequestReadTimeout header=30

You'll likely have to enable the reqtimeout module, as follows:

$ sudo a2enmod reqtimeout
$ sudo apache2ctl restart
Martlark
  • 141
  • 7