squid-1.1.16

・Linux


1. squid-1.1.16 とは

Proxyサーバを実現するソフトです。Firewallで閉じたLANなどから外部のWebサイトを見に行くときに必要となります。もっともよく使われているProxyサーバソフトの一つです。apacheのproxyはそんなに高機能ではないそうなので、これと組み合わせるほうがよいでしょう。


2. squid-1.1.16 のインストール

2.1. ソースの入手

squid-1.1.16-src.tar.gz

2.2. ソースの展開

% tar xzvf squid-1.1.16-src.tar.gz -C /usr/src
% cd /usr/src/squid-1.1.16

2.3. Configure

% ./configure

2.4. Make

% make all

2.5. Install

% su
# make install
# exit

2.6. Clean

% make clean

3. 環境設定

3.1. squid.confの設定

アクセス制御や監視ポート、動作ユーザなどを設定します。

--- squid.conf.default  Sun Sep 28 21:52:19 1997
+++ squid.conf  Sun Sep 28 22:44:39 1997
@@ -8,14 +8,14 @@
 #      requests.  Default is 3128, for httpd-accel mode use port 80.
 #      May be overridden with -a on the command line.
 #
-#http_port 3128
+http_port 8080
 
 #  TAG: icp_port
 #      The port number where squid send and receive ICP requests to
 #      and from neighbor caches.  Default is 3130.  To disable use
 #      "0".  May be overridden with -u on the command line.
 #
-#icp_port 3130
+icp_port 0
 
 #  TAG: mcast_groups
 #       This tag specifies a list of multicast groups which your
@@ -782,6 +782,7 @@
 acl manager proto cache_object
 acl localhost src 127.0.0.1/255.255.255.255
 acl all src 0.0.0.0/0.0.0.0
+acl hogehoge src 192.168.0.0/255.255.255.0
 
 acl SSL_ports port 443 563
 acl Dangerous_ports port 7 9 19
@@ -809,7 +810,7 @@
 
 
 # Only allow access to the cache manager functions from the local host.
-http_access deny manager !localhost
+http_access deny manager !localhost !hogehoge
 http_access deny CONNECT !SSL_ports
 http_access deny Dangerous_ports
 
@@ -864,7 +865,7 @@
 #      UID/GID to the UID/GID specified below.  The default is not to
 #      change UID/GID.
 #
-#cache_effective_user nobody nogroup
+cache_effective_user nobody nogroup
 
 #  TAG: visible_hostname
 #      If you want to present a special hostname in error messages, etc,

3.2. キャッシュディレクトリの作成など

最初はキャッシュディレクトリを作成させます。

% su
# /usr/local/squid/bin/squid -D -z
# chown -R nobody.nogroup /usr/local/squid/cache

3.3. テスト

本来は-Dオプションはいらないのですが、ダイヤルアップ環境では普通は外部にアクセスできないので-Dをつけたままにします。

# /usr/local/squid/bin/squid -D

/usr/local/squid/logs/cache.logに詳細がでていますのでエラーがないかチェックしてみてください。
また、ブラウザのproxyを設定して、アクセスできるかどうかを試してみてください。


4. 使い方

ブート時に起動するように設定します。

起動スクリプト(Linuxなら/etc/rc.d/rc.local)に以下のように記述します。

#
# start squid
#
if [ -x /usr/local/squid/bin/squid ]; then
    /usr/local/squid/bin/squid -D &
    echo -n ' squid'
fi