Re: Cisco Cache Director (Was RE: Does Squid beat the rest? )

From: Miquel van Smoorenburg <miquels@dont-contact.us>
Date: 21 Sep 1997 04:39:59 +0200

In article <Pine.LNX.3.95.970920184153.11052A-100000@nightshade.z.ml.org>,
Gregory Maxwell <nullc@nightshade.z.ml.org> wrote:
>
>You can do this with Linux and Squid.. It's called transparent proxing,
>unfortuantly there is a rather BIG problem with this, The cache only sees
>the IP and not the URL, so it severly reduces hit rate.. Some people on
>this list use Transparent proxying, they can tell you how it works..

But, the code is _in there_ to proxy based on URL. Because the URL is passed
in the Host: header. It's just not turned on for transparent proxying,
but it is for the accelerator code.

A while ago I posted a patch like the following for squid 1.11 but I never
actually tested it myself (in the great Linus Torvalds tradition :)) however
it did compile. On inspection later I found out it probably didn't work.

I redid it for squid-1.16, this one should work. Here it is
(Leigh if you're reading this you might want to try it :))

diff -ruN squid-1.1.16/src/icp.c squid-1.1.16.test/src/icp.c
--- squid-1.1.16/src/icp.c Thu Aug 21 21:20:04 1997
+++ squid-1.1.16.test/src/icp.c Sun Sep 21 04:35:58 1997
@@ -1651,9 +1651,30 @@
         *t = '\0';
     if ((t = strchr(url, '#'))) /* remove HTML anchors */
         *t = '\0';
- /* see if we running in httpd_accel_mode, if so got to convert it to URL */
- if (httpd_accel_mode && *url == '/') {
- /* prepend the accel prefix */
+
+ /*
+ * If we're not in acceleration mode, and we get a request without
+ * a hostname look for a Host: header. This is useful for
+ * transparent proxies.
+ */
+ if (!httpd_accel_mode && *url == '/' &&
+ (t = mime_get_header(req_hdr, "Host")) != NULL) {
+ strtok(t, " :/;@");
+ url_sz = strlen(url) + strlen(t) + 32 + Config.appendDomainLen;
+ icpState->url = xcalloc(url_sz, 1);
+ if (Config.Accel.port != 80)
+ sprintf(icpState->url, "http://%s:%d%s",
+ t, (int) Config.Accel.port, url);
+ else
+ sprintf(icpState->url, "http://%s%s", t, url);
+
+ debug(12, 5, "TRANSPROXY REWRITE: '%s'\n", icpState->url);
+ } else if (httpd_accel_mode && *url == '/') {
+ /*
+ * If we running in httpd_accel_mode, got to convert it to URL.
+ *
+ * Prepend the accel prefix
+ */
         if (vhost_mode) {
             /* Put the local socket IP address as the hostname */
             url_sz = strlen(url) + 32 + Config.appendDomainLen;
 

-- 
| Miquel van Smoorenburg |                                                    |
| miquels@cistron.nl     | Owners of digital watches, your days are numbered. |
|     PGP fingerprint: FE 66 52 4F CD 59 A5 36  7F 39 8B 20 F1 D6 74 02       |
Received on Sat Sep 20 1997 - 19:45:26 MDT

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