You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Danijel <ap...@ml.rbfh.de> on 2009/10/01 16:25:11 UTC

[users@httpd] HTTP/0.9 and mod_proxy

Hi,

I have to reverse proxy a beast which speaks HTTP/0.9. The documentation
to mod_proxy says:

	This module implements a proxy/gateway for Apache. It implements
	proxying capability for FTP, CONNECT (for SSL), HTTP/0.9,
        HTTP/1.0, and HTTP/1.1.

The configuration simply is:

	ProxyPass / http://backend:9110/

But all I get is error 502. The log says: 

	error reading status line from remote server backend

The tcpdump between Apache and the backend looks like this:

	GET /test HTTP/1.0
	Host: backend:9110
	User-Agent: curl/7.15.1 (x86_64-suse-linux) libcurl/7.15.1
	OpenSSL/0.9.8a zlib/1.2.3 libidn/0.6.0
	Accept: */*
	Max-Forwards: 10
	X-Forwarded-For: 127.0.0.1
	X-Forwarded-Host: localhost:4080
	X-Forwarded-Server: localhost

	<html><head/><body>AS2 Adapter is alive.</body></html>

Also I've looked into the code:

    while (received_continue) {
        apr_brigade_cleanup(bb);

        len = ap_getline(buffer, sizeof(buffer), rp, 0);
        if (len == 0) {
            /* handle one potential stray CRLF */
            len = ap_getline(buffer, sizeof(buffer), rp, 0);
        }
        if (len <= 0) {
            apr_socket_close(p_conn->sock);
            backend->connection = NULL;
            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                          "proxy: error reading status line from remote "
                          "server %s", p_conn->name);
            return ap_proxyerror(r, HTTP_BAD_GATEWAY,
                                 "Error reading from remote server");
        }

So, the error is raised when len is <= 0. So, why is len <= 0 with the input
above?

-Danijel

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] HTTP/0.9 and mod_proxy

Posted by Krist van Besien <kr...@gmail.com>.
On Mon, Oct 5, 2009 at 8:30 PM, Danijel <ap...@ml.rbfh.de> wrote:
> Krist van Besien wrote:
>> > The tcpdump between Apache and the backend looks like this:
>> >
>> >        GET /test HTTP/1.0
>> >        Host: backend:9110
>> >        User-Agent: curl/7.15.1 (x86_64-suse-linux) libcurl/7.15.1
>> >        OpenSSL/0.9.8a zlib/1.2.3 libidn/0.6.0
>> >        Accept: */*
>> >        Max-Forwards: 10
>> >        X-Forwarded-For: 127.0.0.1
>> >        X-Forwarded-Host: localhost:4080
>> >        X-Forwarded-Server: localhost
>> >
>> >        <html><head/><body>AS2 Adapter is alive.</body></html>
>>
>> Your problem is that apache expects a http/1.0 response to an HTTP/1.0
>> request. Because the response does not conform to HTTP/1.0 it is
>> rejected. Thus the 502 error.
>>
>> Apache will proxy HTTP/0.9 just fine. Just repeat your test with a
>> HTTP/0.9 client and you'll see. Apache does not translate between
>> HTTP/1.0 and HTTP/0.9. It would anyway not be easy to do this. So if
>> you send a HTTP/1.0 request to your forward proxy it will forward a
>> HTTP/1.0 request to the backend.
>
> I've done that today. The error is the same.

What does the TCP dump show now?

Krist


-- 
krist.vanbesien@gmail.com
krist@vanbesien.org
Bremgarten b. Bern, Switzerland
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] HTTP/0.9 and mod_proxy

Posted by Danijel <ap...@ml.rbfh.de>.
Krist van Besien wrote:
> > The tcpdump between Apache and the backend looks like this:
> >
> >        GET /test HTTP/1.0
> >        Host: backend:9110
> >        User-Agent: curl/7.15.1 (x86_64-suse-linux) libcurl/7.15.1
> >        OpenSSL/0.9.8a zlib/1.2.3 libidn/0.6.0
> >        Accept: */*
> >        Max-Forwards: 10
> >        X-Forwarded-For: 127.0.0.1
> >        X-Forwarded-Host: localhost:4080
> >        X-Forwarded-Server: localhost
> >
> >        <html><head/><body>AS2 Adapter is alive.</body></html>
> 
> Your problem is that apache expects a http/1.0 response to an HTTP/1.0
> request. Because the response does not conform to HTTP/1.0 it is
> rejected. Thus the 502 error.
> 
> Apache will proxy HTTP/0.9 just fine. Just repeat your test with a
> HTTP/0.9 client and you'll see. Apache does not translate between
> HTTP/1.0 and HTTP/0.9. It would anyway not be easy to do this. So if
> you send a HTTP/1.0 request to your forward proxy it will forward a
> HTTP/1.0 request to the backend.

I've done that today. The error is the same.

Danijel

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] HTTP/0.9 and mod_proxy

Posted by Krist van Besien <kr...@gmail.com>.
On Thu, Oct 1, 2009 at 4:25 PM, Danijel <ap...@ml.rbfh.de> wrote:
> Hi,
>
> I have to reverse proxy a beast which speaks HTTP/0.9. The documentation
> to mod_proxy says:
>
>        This module implements a proxy/gateway for Apache. It implements
>        proxying capability for FTP, CONNECT (for SSL), HTTP/0.9,
>        HTTP/1.0, and HTTP/1.1.
>
> The configuration simply is:
>
>        ProxyPass / http://backend:9110/
>
> But all I get is error 502. The log says:
>
>        error reading status line from remote server backend

You get this error because the backend didn't send a status line.
Apache is behaving exactly as designed here.


> The tcpdump between Apache and the backend looks like this:
>
>        GET /test HTTP/1.0
>        Host: backend:9110
>        User-Agent: curl/7.15.1 (x86_64-suse-linux) libcurl/7.15.1
>        OpenSSL/0.9.8a zlib/1.2.3 libidn/0.6.0
>        Accept: */*
>        Max-Forwards: 10
>        X-Forwarded-For: 127.0.0.1
>        X-Forwarded-Host: localhost:4080
>        X-Forwarded-Server: localhost
>
>        <html><head/><body>AS2 Adapter is alive.</body></html>

Your problem is that apache expects a http/1.0 response to an HTTP/1.0
request. Because the response does not conform to HTTP/1.0 it is
rejected. Thus the 502 error.

Apache will proxy HTTP/0.9 just fine. Just repeat your test with a
HTTP/0.9 client and you'll see. Apache does not translate between
HTTP/1.0 and HTTP/0.9. It would anyway not be easy to do this. So if
you send a HTTP/1.0 request to your forward proxy it will forward a
HTTP/1.0 request to the backend.

Krist

-- 
krist.vanbesien@gmail.com
krist@vanbesien.org
Bremgarten b. Bern, Switzerland
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] HTTP/0.9 and mod_proxy

Posted by Danijel <ap...@ml.rbfh.de>.
Karel Kubat wrote:
> On Oct 1, 2009, at 4:25 PM, Danijel wrote:
> > 	GET /test HTTP/1.0
> > 	Host: backend:9110
> > 	User-Agent: curl/7.15.1 (x86_64-suse-linux) libcurl/7.15.1
> > 	OpenSSL/0.9.8a zlib/1.2.3 libidn/0.6.0
> > 	Accept: */*
> > 	Max-Forwards: 10
> > 	X-Forwarded-For: 127.0.0.1
> > 	X-Forwarded-Host: localhost:4080
> > 	X-Forwarded-Server: localhost
> >
> > 	<html><head/><body>AS2 Adapter is alive.</body></html>
> 
> This isn't the right part of the tcpdump. The back end must reply with  
> something like:
>    HTTP/1.1 200 OK
>    Content-length: ... whatever
> 
>    and some content

Well, The thing above the empty line is what was sent (the
request). The HTML part is the thing that was received (the response).
I'm talking about HTTP/0.9 as specified here:

	http://www.w3.org/Protocols/HTTP/AsImplemented.html

There are no Response Headers in HTTP/0.9. The Answer simply contains
the contents of the requested resource.

The question is: Apache receives the following line:

<html><head/><body>AS2 Adapter is alive.</body></html>

So why is "len" <= 0? (Only when len is <= 0 the error is triggered).
Btw, this is Apache 2.0.63.

Danijel

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] HTTP/0.9 and mod_proxy

Posted by Karel Kubat <ka...@e-tunity.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

On Oct 1, 2009, at 4:25 PM, Danijel wrote:

> I have to reverse proxy a beast which speaks HTTP/0.9. The  
> documentation
> to mod_proxy says:
>
> 	This module implements a proxy/gateway for Apache. It implements
> 	proxying capability for FTP, CONNECT (for SSL), HTTP/0.9,
>        HTTP/1.0, and HTTP/1.1.
>
> The configuration simply is:
>
> 	ProxyPass / http://backend:9110/
>
> But all I get is error 502. The log says:
>
> 	error reading status line from remote server backend
>
> The tcpdump between Apache and the backend looks like this:
>
> 	GET /test HTTP/1.0
> 	Host: backend:9110
> 	User-Agent: curl/7.15.1 (x86_64-suse-linux) libcurl/7.15.1
> 	OpenSSL/0.9.8a zlib/1.2.3 libidn/0.6.0
> 	Accept: */*
> 	Max-Forwards: 10
> 	X-Forwarded-For: 127.0.0.1
> 	X-Forwarded-Host: localhost:4080
> 	X-Forwarded-Server: localhost
>
> 	<html><head/><body>AS2 Adapter is alive.</body></html>

This isn't the right part of the tcpdump. The back end must reply with  
something like:
   HTTP/1.1 200 OK
   Content-length: ... whatever

   and some content
You're looking at the request that goes to the back end, not the back  
ends' response.

If you've used the trick "follow tcp stream" in your Wireshark, and  
have only seen the above, then indeed there is no back end response to  
be found, so the proxy rightfully says: error reading status line from  
remote server backend.
- --
Best regards / met vriendelijke groet, Karel Kubat
Mob +31 6 2956 4861

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)

iEUEARECAAYFAkrFEbMACgkQ23FrzRzybNVpsgCgq541f3Dv7HBQczAiVHU1EsQ5
VngAmKtg7f4DJkZNhLHVmtUg8a6+lb0=
=b2gT
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org