Online Book Reader

Home Category

Squid_ The Definitive Guide - Duane Wessels [55]

By Root 1954 0
requires user authentication

#

ST=`squidclient 'http://$TESTHOST/' | head -1 | awk '{print $2}'`

if test "$ST" != 407 ; then

echo "Squid allowed request without proxy authentication"

fi

# make sure Squid denies requests from foreign IP addresses

# elsewhere we already created an alias 192.168.1.1 on one of

# the system interfaces

#

EXT_ADDR=192.168.1.1

ST=`squidclient -l $EXT_ADDR 'http://$TESTHOST/' | head -1 | awk '{print $2}'`

if test "$ST" != 403 ; then

echo "Squid allowed request from external address $EXT_ADDR"

fi

exit 0

Exercises

Define an ACL for each known type (src, dst, ident, etc.) and write a rule that uses all of them.

Intentionally mistype the name of an ACL in one of your rules. Does squid -k parse catch the error? Does Squid start anyway?

Write an http_access that uses slow ACLs, like srcdomain or ident. Time how long Squid takes to serve a request with and without the slow ACL checks.

Chapter 7. Disk Cache Basics

I'm going to talk a lot about disk storage and filesystems in this chapter. It is important to make sure you understand the difference between two related things: disk filesystems and Squid's storage schemes.

Filesystems are features of particular operating systems. Almost every Unix variant has an implementation of the Unix File System (UFS). It is also sometimes known as the Berkeley Fast File System (FFS). Linux's default filesystem is called ext2fs. Many operating systems also support newer filesystem technologies. These include names and acronyms such as advfs, xfs, and reiserfs.

Programs (such as Squid) interact with filesystems via a handful of system calls. These are functions such as open( ), close( ), read( ), write( ), stat( ), and unlink( ). The arguments to these system calls are either pathnames (strings) or file descriptors (integers). Filesystem implementation details are hidden from programs. They typically use internal data structures such as inodes, but Squid doesn't know about that.

Squid has a number of different storage schemes. The schemes have different properties and techniques for organizing and accessing cache data on the disk. Most of them use the filesystem interface system calls (e.g., open( ), write( ), etc.).

Squid has five different storage schemes: ufs, aufs, diskd, coss, and null. The first three use the same directory layout, and they are thus interchangeable. coss is an attempt to implement a new filesystem specifically optimized for Squid. null is a minimal implementation of the API: it doesn't actually read or write data to/from the disk.

* * *

Tip

Due to a poor choice of names, "UFS" might refer to either the Unix filesystem or the Squid storage scheme. To be clear here, I'll write the filesystem as UFS and the storage scheme as ufs.

* * *

The remainder of this chapter focuses on the squid.conf directives that control the disk cache. This includes replacement policies, object removal, and freshness controls. For the most part, I'll only talk about the default storage scheme: ufs. We'll get to the alternative schemes and other tricks in the next chapter.

The cache_dir Directive

The cache_dir directive is one of the most important in squid.conf. It tells Squid where and how to store cache files on disk. The cache_dir directive takes the following arguments:

cache_dir scheme

directory

size

L1

L2 [options]

Scheme

Squid supports a number of different storage schemes. The default (and original) is ufs. Depending on your operating system, you may be able to select other schemes. You must use the —enable-storeio = LIST option with ./configure to compile the optional code for other storage schemes. I'll discuss aufs, diskd, coss, and null in Section 8.7. For now, I'll only talk about the ufs scheme, which is compatible with aufs and diskd.

Directory

The directory argument is a filesystem directory, under which Squid stores cached objects. Normally, a cache_dir corresponds to a whole filesystem or disk partition. It usually doesn't make sense to put more than one cache directory on a single

Return Main Page Previous Page Next Page

®Online Book Reader