最終更新日: 2014年1月13日
Squid Home / FAQトップ

19. Squid バージョン2

19.1 新しい機能は何ですか?

19.2 'ssl_proxy'はどのように設定しますか?

デフォルトでは、SquidはSSLリクエストの場合にはオリジナルサーバへ直接接続します。 しかし、もしあなたがSSLリクエストを親サーバを経由して接続したいなら、SSLリクエストを直接接続しないように最初に指定してください:

acl SSL method CONNECT
never_direct allow SSL

これと同時に、SSLリクエストを使う場合の親を1つだけ指定すべきです。 もし特別な親を指定するなら "cache_peer_access" で設定します。

cache_peer parent1 parent 3128 3130
cache_peer parent2 parent 3128 3130
cache_peer_access parent2 allow !SSL

こうすることで、SquidはSSLにparent2を使わずに、常にparent1を使うようになります。

19.3 ログファイルのローテションがAsync I/Oで働きません。

これはLinuxの Async I/O を使う際の制限です。 Linuxのスレッドパッケージは内部でこっそりSquidのログローテーションで使うSIGUSR1シグナルを盗みます。 
順序の良くないスレッドがLinuxで可能になっているなら、SquidのSIGUSR1は無効にされてしまいます。

19.4 新しいキャッシュディスクの追加。

squid.conf に cache_dir を追加するだけであとは squid -z を実行するだけで簡単です。
Squidは新しいキャッシュディスクを作成、古いものはそのまま残しておきます。

19.5 LinuxでのSquidのまずい働き

Henrik Nordstrom より:

あなたは非同期I/Oを有効にする為にconfigureオプションに --enable-async-io を指定したかも知れません。 スレッドを使うLinuxで最新のバージョンのlibc5か早い時期のバージョンのglibcを使うスレッドアプリケーションでは問題がある事を知っておいてください。
あなたのシステムがglibc 2.1.3もしくはそれ以降のものを使うことがない限り、私は Linux で --enable-async-io を推薦しないでしょう。

あなたがとても忙しいキャッシュを持っていることがない限り、--enable-async-io が最良でないことを知っているべきです。低いロードであるキャッシュは、--enable-async-io なしでもうまく働きます。

--enable-async-io を外してSquidを再コンパイルして下さい。 これによって正常に動作するならあなたのlibcはおそらくスレッドの操作に問題があります。(configureの際に"make clean"を忘れないでください。)

19.6 Squidではどうやってproxy認証を行いますか?

Squid-2からは、その実装と設定は変更されました。認証は現在、外部のプロセス経由で処理されます。Arjan'sによるproxy auth pageページにはそれを始める方法が述べられています。シンプルな手順を以下に説明します。

  1. あなたは、外部の認証プログラムをコンパイルしてインストールする必要があるでしょう。ほとんどの場合は ncsa_auth を使うと思います。このプログラムは、ソースファイルの auth_modules/NCSA ディレクトリに含まれています。

    % cd auth_modules/NCSA (※正確には src/helpers/basic_auth/NCSA )
    % make
    % make install

    ncsa_auth プログラムは、squidのバイナリがあるのと同じディレクトリに置いておくと良いでしょう。

    ※rpmなどのパッケージでsquidをインストールしてある場合には、既に認証プログラムがコンパイルされている事もあるので、必要に応じてコンパイルするようにしてください。(Debianでは殆どの認証プログラムが/usr/lib/squid以下に既に存在しているようです)
  2. パスワード・ファイルを作る必要があります。もし以前にプロキシ認証を使っていれば既にあなたはパスワードファイルを持っている事でしょう。 あなたは apache's htpasswd program を私たちのサーバから入手できます。
    パスワード・ファイルのためにパス名を選んで下さい。

    # htpasswd -c /usr/local/squid/etc/passwd username
    New password:
    Re-type new password:

    (-c オプションを付けると改めてパスワードファイルを作成します。 追加の場合には-cを付けずに実行してください)

  3. squid.confで外部の認証を構成して下さい。ncsa_authのために、あなたは、実行可能ファイルへのパス名と引数としてのパスワード・ファイルを与える必要があります。 

    例:

    auth_param basic program /usr/lib/squid/ncsa_auth /usr/local/squid/etc/passwd # ソースファイルからコンパイルしたならncsa_auth は/usr/local/squid/libexec/ncsa_authです)
    auth_param basic children 5
    auth_param basic realm Squid proxy-caching web server
    auth_param basic credentialsttl 2 hours

  4. proxy_authを使ったACLエントリのを作成:

    acl foo proxy_auth REQUIRED
    acl localnet src 192.168.1.0/255.255.255.0
    http_access allow localnet foo

すべての設定が終わったならSquidを起動してください。 もし何か抜けている事があればどうか私たち(squid-faq@squid-cache.org)に知らせてください。

これ以外の認証に関する資料はこちらをご覧ください。

19.7 何故Squid-2.1以前からアップデートするとproxy-authですべてのユーザがはじかれますか?

プロキシー認証のためのACLが以下のように変わりました

(以前)

acl foo proxy_auth timeout

(現在)

acl foo proxy_auth username

どうかあなたのACLを適正に更新して下さい。- ユーザー名には適正な名前が必要です。タイムアウトの設定は、構成オプションで以下のようにします。:

auth_param basic credentialsttl timeout

19.8 Delay Pools

David Luyer による:

この情報はバージョン2.2現在の情報です。 もしあなたがdelay poolsを使いたいのであれば、最新のSquid-2.2を使うことを強くお勧めします。

リストに基づく限定されるリクエストのバンド幅を制限するために、Delayプールは方法を提供します。 
このアイデアは、学生のアクセスによる帯域コストを制限(スタッフトラフィックと静的なキャッシュとローカルのpeerヒットはハイスピードのままで)したかったWestern Australian university(西オーストラリア大学)から来ています。 
これらは私がはるかに多くの複雑なパッチへを開発したマードック大学(オーストラリア西部大学の事)に中央ネットワークサービスにSquid 1.0のコードとしてありこれを"DELAY_HACK"と呼んでいました。 
個人的な必要からそれを私は、クリーンで商標にかからない形式でこれに暗号化するように試みSquid-2の"delay pools"と呼びました。 

私は多くの人のリクエストによってSquid-2.2においても利用できるようにしました。

Squid-2.2でdelay poolsを有効にするには、--enable-delay-pools をconfigureのオプションで指定してコンパイルしてください。

このFAQで使われる用語:

pool(プール)

適切なクラスを与えるバケットグループとしてのまとまり。

bucket group(バケットグループ)

プール内のバケットのまとまり。 例えば per-host bucket group(ピアホスト バケット グループ), per-network bucket group(ピアネットワーク バケットグループ)、または aggregate bucket group(総計 バケット グループ)。(aggregate bucket group(総計 バケット グループ) は実際には1つのバケットです)

bucket

個々の延期バケツは、所定の割合(与えられた限界まで)で再び満たされて、そして空っぽである場合にはトラフィックを遅らせさせられるトラフィック・アロケーションを表します。

class

クラスはどのくらいの遅延を行うかのdelay poolを決定する。 例えば、異なるクライアントIPが別々またはグループとして扱われる(または両方)かを決定します。

class 1

class 1 delay pool(クラス1延期プール)は、host subjectからプールへすべての依頼に利用されるひとつの統一されたバケットです。

class 2

class 2 delay pool は1つの統一のバケットと256のバケットで、各バケットは8ビットのネットワーク(IPv4 のクラスC)のホストを表します。

class 3

16ビットのサブネットのための256個のバケットで、各バケットはこれら16ビット(IPv4のクラスB)のネットワークを表します。

Delay pools はクライアントおよびクライアントグループへのトラフィック制限を様々な機能で許可します:

この許可オプションは、クラス1のdelay poolの番号の作成や、与えられたオブジェクト・タイプ(URL正規表現の使用による、あるいは類似した)へのある量の帯域幅および比較的小さなトラフィックを大きなトラフィックとの割合によって公正に帯域が使えるようにするような帯域幅の利用を許可します。

delay poolには幾つかの制限があります。

■ どうやってSquidは512Kbpsの帯域に制限できますか?

acl all src 0.0.0.0/0.0.0.0 # might already be defined
delay_pools 1
delay_class 1 1
delay_access 1 allow all
delay_parameters 1 64000/64000 # 512 kbits == 64 kbytes per second

これらのタグの説明のために、構成(configuration)ファイルを見てください。

1秒間のバッファ(max = restore = 64kbytes/sec)として制限する要求であり、瞬発的な感応(busrt is requested)ではありません。
もし、 瞬発的な感応をして欲しい場合には、aggregate_max の値をより大きなものにしてください。そうすれば、トラフィックバーストを処理することができるでしょう。
単一のオブジェクトだけがダウンロードされている場合、バケットが空でないように、ダウンロード割合は要求された処理能力以下に下げられるでしょう。

■ 特定の1つを128Kbpsで制限した場合は?

単一のHTTPリクエストの接続速度を制限することができません。個々のホストをある帯域幅割合に制限することができます。特定のホストを制限するためには、そのホストのためのaclを定義して、上記の例を使用してくだい。その後、1グループのホストを制限するために、クラス2あるいは3のdelay poolを使用しなければなりません。例えば:

acl only128kusers src 192.168.1.0/255.255.192.0
acl all src 0.0.0.0/0.0.0.0
delay_pools 1
delay_class 1 3
delay_access 1 allow only128kusers
delay_access 1 deny all
delay_parameters 1 64000/64000 -1/-1 16000/64000

これらのタグの説明のために、構成(configuration)ファイルを見てください。

上記が作用させるためにキャッシュが合計512kbitsが与えられるます。そしてそれぞれのIPアドレスは、そのプールから128kbitsを得ます。

■ 個人的にはどうやってdaley poolsを使いますか?

私たちはオプションを"proxy-only no-delay"とした6つのローカルのキャッシュpeerを使っており、これらはfast ethernetやマイクロウェーブ(ATM)でつながっています。

私たちのローカルなアクセスについては、dstdomain ACLを使用します。また、delay pool例外としてdelay poolの処理において"fast lookups"(DNS検査のための手段)の為に、dst ACLを使います。 

我々のプロキシは、2つの仮想インターフェースを持っています。 1つは認証が必要な学生からの接続リクエストでトラフィックの課金をしていないもののためのdelay pool 。 また、主なUnixシステムのユーザーは、遅いまたは速いトラフィックを選ぶことができますが、速いキャッシュを使う場合にはトラフィックの課金が必要になります。彼らが必要とされないので、Ident探索は、遅いキャッシュを通してアクセスできません。 遅いアクセスの遅延には、クラス3のdelay poolを使い、部間やユーザ間の公平を取ります。 我々は、主なホストのlynxのユーザーが1つの遅れバケツで共にまとめられるようにしています。これらは、たいがいはテキスト・ページを見ていので帯域への深刻な問題とみなされていません。 それが我々だった場合には、ホストをクラス1遅れプールに運んで、そしてより大きいアロケーションを与えるかもしれません。

I prefer using a slow restore rate and a large maximum rate to give preference to people who are looking at web pages as their individual bucket fills while they are reading, and those downloading large objects are disadvantaged. This depends on which clients you believe are more important. Also, one individual 8 bit network (a residential college) have paid extra to get more bandwidth.

私の構成ファイルの該当部分 (IP addresses, etc, all changed):

# ACL definitions
# Local network definitions, domains a.net, b.net
acl LOCAL-NET dstdomain a.net b.net
# Local network; nets 64 - 127. Also nearby network class A, 10.
acl LOCAL-IP dst 192.168.64.0/255.255.192.0 10.0.0.0/255.0.0.0
# Virtual i/f used for slow access
acl virtual_slowcache myip 192.168.100.13/255.255.255.255
# All permitted slow access, nets 96 - 127
acl slownets src 192.168.96.0/255.255.224.0
# Special 'fast' slow access, net 123
acl fast_slow src 192.168.123.0/255.255.255.0
# User hosts
acl my_user_hosts src 192.168.100.2/255.255.255.254
# "All" ACL
acl all src 0.0.0.0/0.0.0.0

# Don't need ident lookups for billing on (free) slow cache
ident_lookup_access allow my_user_hosts !virtual_slowcache
ident_lookup_access deny all

# Security access checks
http_access [...]

# These people get in for slow cache access
http_access allow virtual_slowcache slownets
http_access deny virtual_slowcache

# Access checks for main cache
http_access [...]

# Delay definitions (read config file for clarification)
delay_pools 2
delay_initial_bucket_level 50

delay_class 1 3
delay_access 1 allow virtual_slowcache !LOCAL-NET !LOCAL-IP !fast_slow
delay_access 1 deny all
delay_parameters 1 8192/131072 1024/65536 256/32768

delay_class 2 2
delay_access 2 allow virtual_slowcache !LOCAL-NET !LOCAL-IP fast_slow
delay_access 2 deny all
delay_parameters 2 2048/65536 512/32768

同じコードも、異なる実験室あるいは学生とは異なる実行を与える際にそれらにより多くの柔軟性を与えるためにクラス2のdelay pool を使用して、部のうちのいくつかによって使用されます。

■ delay poolについて知るには何処を探せば良いですか?

構成ファイル(configuration)にかなり具体的に記載されてます。 

# DELAY POOL PARAMETERS (all require DELAY_POOLS compilation option)
# -----------------------------------------------------------------------------

# TAG: delay_pools
# This represents the number of delay pools to be used. For example,
# if you have one class 2 delay pool and one class 3 delays pool, you
# have a total of 2 delay pools.
#
# To enable this option, you must use --enable-delay-pools with the
# configure script.
#delay_pools 0

# TAG: delay_class
# This defines the class of each delay pool. There must be exactly one
# delay_class line for each delay pool. For example, to define two
# delay pools, one of class 2 and one of class 3, the settings above
# and here would be:
#
#delay_pools 2 # 2 delay pools
#delay_class 1 2 # pool 1 is a class 2 pool
#delay_class 2 3 # pool 2 is a class 3 pool
#
# The delay pool classes are:
#
# class 1 Everything is limited by a single aggregate
# bucket.
#
# class 2 Everything is limited by a single aggregate
# bucket as well as an "individual" bucket chosen
# from bits 25 through 32 of the IP address.
#
# class 3 Everything is limited by a single aggregate
# bucket as well as a "network" bucket chosen
# from bits 17 through 24 of the IP address and a
# "individual" bucket chosen from bits 17 through
# 32 of the IP address.
#
# NOTE: If an IP address is a.b.c.d
# -> bits 25 through 32 are "d"
# -> bits 17 through 24 are "c"
# -> bits 17 through 32 are "c * 256 + d"

# TAG: delay_access
# This is used to determine which delay pool a request falls into.
# The first matched delay pool is always used, ie, if a request falls
# into delay pool number one, no more delay are checked, otherwise the
# rest are checked in order of their delay pool number until they have
# all been checked. For example, if you want some_big_clients in delay
# pool 1 and lotsa_little_clients in delay pool 2:
#
#delay_access 1 allow some_big_clients
#delay_access 1 deny all
#delay_access 2 allow lotsa_little_clients
#delay_access 2 deny all

# TAG: delay_parameters
# This defines the parameters for a delay pool. Each delay pool has
# a number of "buckets" associated with it, as explained in the
# description of delay_class. For a class 1 delay pool, the syntax is:
#
#delay_parameters pool aggregate
#
# For a class 2 delay pool:
#
#delay_parameters pool aggregate individual
#
# For a class 3 delay pool:
#
#delay_parameters pool aggregate network individual
#
# The variables here are:
#
# pool a pool number - ie, a number between 1 and the
# number specified in delay_pools as used in
# delay_class lines.
#
# aggregate the "delay parameters" for the aggregate bucket
# (class 1, 2, 3).
#
# individual the "delay parameters" for the individual
# buckets (class 2, 3).
#
# network the "delay parameters" for the network buckets
# (class 3).
#
# A pair of delay parameters is written restore/maximum, where restore is
# the number of bytes (not bits - modem and network speeds are usually
# quoted in bits) per second placed into the bucket, and maximum is the
# maximum number of bytes which can be in the bucket at any time.
#
# For example, if delay pool number 1 is a class 2 delay pool as in the
# above example, and is being used to strictly limit each host to 64kbps
# (plus overheads), with no overall limit, the line is:
#
#delay_parameters 1 -1/-1 8000/8000
#
# Note that the figure -1 is used to represent "unlimited".
#
# And, if delay pool number 2 is a class 3 delay pool as in the above
# example, and you want to limit it to a total of 256kbps (strict limit)
# with each 8-bit network permitted 64kbps (strict limit) and each
# individual host permitted 4800bps with a bucket maximum size of 64kb
# to permit a decent web page to be downloaded at a decent speed
# (if the network is not being limited due to overuse) but slow down
# large downloads more significantly:
#
#delay_parameters 2 32000/32000 8000/8000 600/8000
#
# There must be one delay_parameters line for each delay pool.

# TAG: delay_initial_bucket_level (percent, 0-100)
# The initial bucket percentage is used to determine how much is put
# in each bucket when squid starts, is reconfigured, or first notices
# a host accessing it (in class 2 and class 3, individual hosts and
# networks only have buckets associated with them once they have been
# "seen" by squid).
#
#delay_initial_bucket_level 50

19.9 バージョン1.1から2へのアップグレードの際、私のキャッシュは保護できますか?

今のところ、1.1から2へのキャッシュコンテンツの変換はできません。 多くの人が求めればそのうち誰かがスクリプトを書くでしょう。
よろしかったら、あなたは、兄弟姉妹としてあなたの古いSquid-1.1キャッシュで新しいSquid-2キャッシュを構成することができます。数日または数週間の後で、古いSquidキャッシュを閉めて下さい。もし古いキャッシュからロードを強制することにオブジェクトをもつあなたの新しいキャッシュを望めば、あなたは、このようなことを試みることができます:

  1. Squid-2 をインストールしSquid-1以上のキャッシュスペースを持つように構成してください。
  2. Squid-1を親として、 Squid-2 を構成してください。そして、never_direct を有効にしてSquid-2からのリクエストがSquid-1を通り抜けるようにしてください。
  3. Squid-1の PURGE method を 有効にしてください。
  4. それが隠されたオブジェクトのIMS要求を生みださないようにSquid-1でリフレッシュ規則をセットして下さい。
  5. Squid-1のキャッシュからすべてのURLリストを作成してください。 これは、access.log, store.log , swap の各ログから抽出できます。
  6. 取得したURLリストを使い、これによってSquid-2からSquid-1へ直接PURGEのリクエスト行います。
  7. 結果として Squid-2 は全てのオブジェクトを持ち、 Squid-1 は空っぽになります。

19.10 エラーメッセージのカスタマイズ

Squid-2 はあなたにエラーメッセージのカスタマイズを許しています。ソースファイルには、色々な言語のエラーメッセージが含まれています。 あなたは configure のオプションで言語を選択できます:

--enable-err-language=lang

その上、あなたは、エラー・メッセージ・テンプレート・ファイルを書きなおすことができます。このリストはSquidがメッセージに挿入できるタグについて述べています:

%B
URL with FTP %2f hack
%c
Squid error code
%d
seconds elapsed since request received (not yet implemented)
%e
errno
$E
strerror()
%f
FTP request line
%F
FTP reply line
%g
FTP server message
%h
cache hostname
%H
server host name
%i
client IP address
%I
server IP address
%L
contents of err_html_text config option
%M
Request Method
%m
Error message returned by external auth helper
%p
URL port \#
%P
Protocol
%R
Full HTTP Request
%S
squid default signature
%s
caching proxy software with version
%t
local time
%T
UTC
%U
URL without password
%u
URL with password (Squid-2.5 and later only)
%w
cachemgr email address
%z
dns server error message

%sがエラー・ページで使われることがない限り、Squidデフォルト・シグニチャーは自動的に加えられます。シグニチャーを変えるために、それぞれのエラー・ページに手動でシグニチャーを追加しなくてはいけません。

デフォルトのシグニチャーはこんな感じです:

<BR clear="all">
<HR noshade size="1px">
<ADDRESS>
Generated %T by %h (%s)
</ADDRESS>
</BODY></HTML>

19.11 Squid-1.1のsquid.conf で機能しません!

はい、多くの命令は、名前が変更されました。それらのうちの幾つか:

cache_host
これは今 cache_peer と呼ばれます。古い用語は、何を形成しているか説明していません。しかし、新しい名前は、あなたがキャッシュのための仲間を形成しているとあなたに伝えます。
cache_host_domain
cache_peer_domain に変更されました。
local_ip, local_domain
これらの指令によって提供される機能は、現在ではアクセスコントロールリストとしてインプリメントされます。always_direct と never_direct のオプションを使用を望むなら新しいsquid.confファイルはいくつかの例を持っています。
cache_stoplist
この指令は、さらにアクセスコントロールリストで再インプリメントされました。あなたはno_cacheオプションを使用するでしょう。例えば:
acl Uncachable url_regex cgi ?
no_cache deny Uncachable
cache_swap
このオプションはかつてはキャッシュディスク・サイズを指定しました。今は、 cache_dir にてディスク・サイズを指定します。
cache_host_acl
このオプションはcache_peer_accessに改名されました。また、書式は変わりました。今、このオプションはアクセスコントロールリストで行います。そして、allowを含まなければならないか、キーワードを否定しなければなりません。例えば:
acl that-AS dst_as 1241
cache_peer_access thatcache.thatdomain.net allow that-AS
cache_peer_access thatcache.thatdomain.net deny all
例は、Autonomous System Number が 1241の起源サーバーのためにはpeerキャッシュ thatcache.thatdomain.netにリクエストを送ります。
units
Squid-1.1では、構成オプションの多くが、それらに関連したユニットによって意味が違いました。例えば、 connect_timeout の値は数秒であったかもしれないが、read_timeout の値は 数分で与えなければなりませんでした。
スキッド-2で、これらの指令は数の後にユニットをとります。また、ユニットをやめれば、警告を得るでしょう。例えば、今以下の宛て先に書くべきです:
connect_timeout 120 seconds
read_timeout 15 minutes
Squid Home / FAQトップ

参考: