Probably found a bug in squid 3 cache_peer for reverse proxy

From: Dino Ciuffetti <dino@dont-contact.us>
Date: Fri, 17 Oct 2003 14:27:06 +0200

Hello everybody. We are testing squid 3 with reverse proxy and name
virtualhosts, here are some test we have done.

1) Squid as a frontend reverse proxy of apache http server on the same machine
without the vhost parameter (http_port directive):

It seems to work properly, obviously you don't have virtual hosting support!!

2) Squid as a frontend reverse proxy of apache http server on another machine
without the vhost parameter (http_port directive):

It seems to work properly, obviously you don't have virtual hosting support!!

3) Squid as a frontend reverse proxy of apache http server on the same machine
with the vhost parameter (http_port directive):

It doesn't work and this is the http error reported by squid:

The following error was encountered:
Access Denied.
Access control configuration prevents your request from being allowed at this
time. Please contact your service provider if you feel this is incorrect.
Your cache administrator is webmaster.

And this is my /var/log/messages

Oct 17 13:34:27 london5 squid[15868]: WARNING: Forwarding loop detected for:
GET / HTTP/1.0^M User-Agent: Mozilla/5.0 (compatible; Konqueror/3.1; Linux
2.4.22)^M Accept: text/html, image/jpeg, image/png, text/*, image/*, */*^M
Accept-Encoding: x-gzip, x-deflate, gzip, deflate, identity^M Accept-Charset:
iso-8859-1, utf-8;q=0.5, *;q=0.5^M Accept-Language: it, en^M Cookie:
lang=ita; style_choose_ch=arancio^M Host: 213.86.64.203^M Via: 1.1
firewall.pro-netics2.com:800 (Squid/2.4.STABLE6), 1.0
testfrimmgroup.pro-netics.com (squid/3.0-PRE3-20031014)^M
Surrogate-Capability: unset-id="Surrogate/1.0 ESI/1.0"^M X-Forwarded-For:
unknown, 213.203.150.253^M Cache-Control: max-age=259200^M Connection:
keep-alive^M ^M

I watched the source code of squid and I found that the port isn't specified
when using vhost because the url is rewritten taking the Host header sent by
the browser. Please tell me if I am wrong:

/usr/src/squid-3.0-PRE3-20031014/src/client_side.cc [row 1722]

} else if (vhost && (host = mime_get_header(req_hdr, "Host")) != NULL) {
        int url_sz = strlen(url) + 32 + Config.appendDomainLen +
                     strlen(host);
        http->uri = (char *)xcalloc(url_sz, 1);
        snprintf(http->uri, url_sz, "%s://%s%s",
                 conn->port->protocol, host, url);
        debug(33, 5) ("ACCEL VHOST REWRITE: '%s'\n", http->uri);
    } else if (conn->port->defaultsite) {

Please note the line containing snprintf that write the url taking the Host
heder as an argument. There's no port in the url. This is what I say...

snprintf(http->uri, url_sz, "%s://%s:%d%s",
                 conn->port->protocol, host, (port_cache_peer), url);

where port_cache_peer is the port I defined in cache_peer for the parent cache
peer.

Please help me if I am wrong, scuse me for my stipidity in the case!

Bye, Dino.

-- 
--------------------------------------------
|  Dino Ciuffetti - Network Administrator  |
|      +**+   Pro-Netics S.r.l.  +**+      |
--------------------------------------------
Received on Fri Oct 17 2003 - 06:27:40 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:20:44 MST