Re: httpd-accelerator

From: Henrik Nordstrom <hno@dont-contact.us>
Date: Tue, 06 Apr 1999 11:38:18 +0200

Jan Simek wrote:

> I'd like to dedicate a machine for Squid running in both accelerator and
> proxy modes, and would like it to serve as an accelerator (~ also backup?)
> httpd server for 3 our machines that run many virtual servers... can
> somebody try to sugest the configuration for me? Is there a HOWTO on the
> topic (excpet the FAQ -- I didn't make it according to it...)?

Exactly how you do depends a bit on if you are using IP baser virtual
servers, or Host: based.

> Also -- what exactly happens if there's a request for a page from one of
> our web servers (and Squid is configured to serve the requests for that
> web server)?

In short:

1. Request is received by Squid
1b. On an accelerator, the URL-path is expanded to a full URL using
httpd_accel_host and/or httpd_accel_uses_host_header.
2. Request is matched agains access control definitions
3. the URL is sent to a redirector for possible rewriting/redirection.
4. If the object is fresh in the local cache, then serve it from there.
5. If the object is not fresh or not cached, then the origin/backend
server is contacted

Example of one way to set up a accelerator supporting both IP and Host:
based virtual servers:

Squid host config:
The same number of IP interfaces is configured as you need IP based
hosts/sites. In this example 192.168.1.X illustrates these "Squid"
adresses, while 10.1.1.X illustrates the IP addresses of the backend
servers.

Squid.conf:
httpd_accel_host virutal
httpd_accel_user_host_header on
redirect_program /usr/local/squid/bin/ip-redirector.pl

/etc/hosts:
www.domain1.com 10.1.1.2 # backend server IP 1
www.domain2.com 10.1.1.2 # virtual domain on the same IP
www.domain3.com 10.1.1.3 # backend server IP 2
[and so on]

/etc/nsswitch.conf:
hosts: files dns

/usr/local/squid/bin/ip-redirector.pl:
#!/usr/bin/perl -p
# Frontend IP -> Backend IP
s%^http://192.168.1.1\b%http://10.1.1.2%
# Main site on IP 2
a%^http://192.168.1.2\b%http://10.1.1.3%

Public DNS:
www.domain1.com IN A 192.168.1.1
www.domain2.com IN CNAME www.domain1.com. (or IN A 192.168.1.1)
www.domain3.com IN A 192.168.1.2

Note that you do not neccesary need a 1-1 relation between frontend and
backend IP addresses or URLs. You can for example build a virtual URL
space combining data from several different backend servers into one
domain, or provide IP based access to backend domain based virtual
hosts, or the rewerse or any combination of this.

--
Henrik Nordstrom
Spare time Squid hacker
Received on Tue Apr 06 1999 - 03:43:17 MDT

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