[Zope] Zope, squid, the Host header

Dennis Nichols nichols@tradingconnections.com
Sat, 25 Nov 2000 16:18:55 -0600


The "How-To: Configuring Squid as an Accelerator for Zope" 
(http://www.zope.org/Members/htrd/howto/squid) by htrd doesn't entirely 
work for me and/or is over my head! My goal is to use Squid as an http 
accelerator in front of zope (using zserver, no apache) on the same 
machine. Secondary goal is to be able to access Zope directly also, but 
this is much less important. An alternate How-To by itamar 
(http://www.zope.org/Members/itamar/Squid) requires the use of SiteAccess, 
which I would like to avoid.

Squid seems to be running OK (listening on port 8070, connecting to zope on 
port 8080) but wrestling with zope about the Host header has not yet 
produced a winner. Specifically, the How-To says:

"If you will be always be accessing this Zope server through the 
accelerator then the easiest solution is to configure Zope to ignore the 
value of this header. Specify HTTP_HOST=www.myhost.com as either a 
command-line parameter to z2.py, or as an environment variable."

I translate this to mean I could set and then export an environment 
variable that in my case would be HTTP_HOST=www.myhost.com:8070 since 
that's where the server should appear to be to the browser client. For 
whatever reason, this is not effective. I can tell because zope still works 
fine directly on port 8080 (through port 8070 I get the requested document, 
no images, and the baseref is still at port 8080). Inspection of 
HTTPRequest.py shows that it does a

      if have_env('HTTP_HOST'):
           host = strip(environ['HTTP_HOST'])
           hostname, port = splitport(host)

and sees www.myhost.com:8080. Specifying the HTTP_HOST= on the command line 
has the same (non-) effect. I'd be pretty happy if I got either of those to 
work. I'd be even happier if I got the following to work, also quoted from 
the htrd How-To:

"A better solution is to get Squid to rewrite the header to the correct value:
   1. Compile squid using --disable-internal-dns.
   2. Add a mapping from the name of your public server to
      the IP address of your Zope server in /etc/hosts
   3. If you are running the Zope server on the same machine
      as the accelerator then:
      1. Change the http_port line in squid.conf to bind
         only on the public network interface.
      2. Use the -w switch to Z2.py to get Zope to bind to
         different network interface (possibly a loopback interface).
         Remember to change httpd_accel_host in squid.conf too.

(Thank you to Henrik Nordstrom for showing me that solution.)"

But I really don't understand this method...
   1. OK, I know how to do the compile
   2. /etc/hosts seem to map the other way, from the IP address
      of whatever to a name and some aliases. Does this mean that
      I should have a line 111.222.111.222 myhost.com myhost
      or is something else implied.
   3.1 meaning  "http_port myhost.com:8070" ?
   3.2 this means?

All help sincerely appreciated.


--
Dennis Nichols
nichols@tradingconnections.com