15.3 Gee, That Was Confusing!

Yeah, it was for me too. Let's look at it another way. The settings that you need to use depend on how many backend boxes you have and how many origin server names you are accelerating. Let's consider the four separate cases in the following sections.

15.3.1 One Box, One Server Name

This is the simplest sort of configuration. Because you have only one box and one hostname, the Host header values don't matter much. You should probably use:

httpd_accel_host www.example.com

httpd_accel_single_host on

httpd_accel_uses_host_header off

If you like, you can use an IP address for httpd_accel_host, although it will appear in URIs in your access.log.

15.3.2 One Box, Many Server Names

Because you have many origin server names being virtually hosted on a single box, the Host header becomes important. We want Squid to insert it into the URIs it generates from partial requests. Your configuration should be:

httpd_accel_host www.example.com

httpd_accel_single_host on

httpd_accel_uses_host_header on

In this case, Squid generates the URI based on the Host header. If absent, Squid inserts www.example.com. You can disable httpd_accel_single_host if you prefer. As before, you can use an IP address in httpd_accel_host to avoid DNS lookups.

15.3.3 Many Boxes, One Server Name

This sounds like a load-balancing configuration. One way to accomplish it is to create a DNS name for the backend servers with multiple IP addresses. Squid iterates between all addresses (a.k.a. round-robin) for each cache miss. In this situation, the configuration is the same as for the one box/one name case:

httpd_accel_host roundrobin.example.com

httpd_accel_single_host on

httpd_accel_uses_host_header off

The only difference is that the httpd_accel_host name resolves to multiple addresses. It might look like this in a Berkeley Internet Name Daemon (BIND) zone file:

$ORIGIN example.com.

roundrobin      IN      A      192.168.1.2

                IN      A      192.168.1.3

                IN      A      192.168.1.4

With this DNS configuration, Squid uses the next address in the list each time it opens a new connection to roundrobin.example.com. When it gets to the end of the list, it starts over at the top. Note that Squid caches these DNS answers internally according to their TTLs. You aren't relying on the name server to return the address list in a different order for each DNS query.

Another option is to use a redirector (see Chapter 11) to select the backend server. You can write a simple script to replace the URI hostname (e.g., roundrobin.example.com) with a different hostname or an IP address. You might even make the redirector smart enough to make its selection based on the current state of the backend servers. Use the following configuration with this approach:

httpd_accel_host roundrobin.example.com

httpd_accel_single_host off

httpd_accel_uses_host_header off

15.3.4 Many Boxes, Many Server Names

In this case, you want to use the Host header. You also want Squid to select the backend server based on the origin server's name (i.e., a DNS lookup). The configuration is as follows:

httpd_accel_host www.example.com

httpd_accel_single_host off

httpd_accel_uses_host_header on

You might be tempted to set httpd_accel_host to virtual. However, that would be a mistake unless you are using HTTP interception.



    Appendix A. Config File Reference
     
    ASPTreeView.com
     
    Evaluation has ФЧєШ·ТРШЕЧ№expired.
    Info...