Jonathan Benson wrote:
> find a way to have my log files store the requested URL rather than just
> the IP of the URL.
You need to use
http_accel_uses_host_header on
in your squid.conf
> Finally if you could perhaps give your own explanation of
> what 'virtual' does in the scheme of things it would be
> appreciated.
When Squid runs as a transparent proxy, the mode of operation is
"Accelerate all web servers in the world". This is different from a
normal proxy situation in what the requests look like when they reach
the Squid:
A proxy request looks like the following:
GET http://www.netscape.com/ HTTP/1.0
Host: www.netscape.com
User-Agent: Your favorite browser
....
But a transparent-proxy gets the HTTP server request
GET / HTTP/1.0
Host: www.netscape.com
User-Agent: Your favorite browser
....
To be able to proxy this, Squid has to recover the server part of the
URL somehow. There is two ways to do this, neither of them is perfect.
1. The destination IP (http_accel virtual ...)
Problem: Host: based virtual servers break. The pages are cached on the
IP which is shared by several server names serving different contents =>
The users may get another site from the cache than they requested.
2. The Host: header (http_accel_uses_host_header on)
Problem: Not all clients send a Host: header.
The best you can do is to combine both. Use the Host: header if it is
available, else the destination IP. To do this you need to apply a very
small patch to Squid (attached), and have this in squid.conf:
http_accel virtual 80
http_accel_uses_host_header on
What the patch does, is to change the priority of destination IP vs
Host: header. In the current distribution http_accel virtual has a
higher priority than http_accel_uses_host_header, which makes it
impossible to combine both (the accelerated URLs is always IP based
regardless of how you set http_accel_uses_host_header).
--- Henrik Nordström Sparetime Squid Hacker
*** squid-1.1.20/src/icp.c.orig Thu Dec 18 05:58:54 1997
--- squid-1.1.20/src/icp.c Thu Jan 29 23:08:51 1998
***************
*** 1682,1698 ****
*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 (vhost_mode) {
! /* Put the local socket IP address as the hostname */
! url_sz = strlen(url) + 32 + Config.appendDomainLen;
! icpState->url = xcalloc(url_sz, 1);
! sprintf(icpState->url, "http://%s:%d%s",
! inet_ntoa(icpState->me.sin_addr),
! (int) Config.Accel.port,
! url);
! debug(12, 5, "VHOST REWRITE: '%s'\n", icpState->url);
! } else if (opt_accel_uses_host && (t = mime_get_header(req_hdr, "Host"))) {
/* If a Host: header was specified, use it to build the URL
* instead of the one in the Config file. */
/*
--- 1682,1689 ----
*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 (opt_accel_uses_host && (t = mime_get_header(req_hdr, "Host"))) {
/* If a Host: header was specified, use it to build the URL
* instead of the one in the Config file. */
/*
***************
*** 1707,1712 ****
--- 1698,1712 ----
icpState->url = xcalloc(url_sz, 1);
sprintf(icpState->url, "http://%s:%d%s",
t, (int) Config.Accel.port, url);
+ } else if (vhost_mode) {
+ /* Put the local socket IP address as the hostname */
+ url_sz = strlen(url) + 32 + Config.appendDomainLen;
+ icpState->url = xcalloc(url_sz, 1);
+ sprintf(icpState->url, "http://%s:%d%s",
+ inet_ntoa(icpState->me.sin_addr),
+ (int) Config.Accel.port,
+ url);
+ debug(12, 5, "VHOST REWRITE: '%s'\n", icpState->url);
} else {
url_sz = strlen(Config.Accel.prefix) + strlen(url) +
Config.appendDomainLen + 1;
Received on Thu Jan 29 1998 - 16:03:36 MST
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:38:34 MST