HTTP Proxyといえばsquidだろう。
っていうことでメモ。
ここでは匿名プロキシの設定をすることとする。
ユーザ認証のアクセスコントロールや細かい設定は別ファイルに記述するとして、基本部分は/etc/squid3/squid.confに記述。
squid.confではアクセスを許可するのはマネージャとローカルホストからのアクセスのみとする。
acl manager proto cache_object acl localhost src 127.0.0.1/32 acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 acl SSL_ports port 443 acl Safe_ports port 80 # http acl Safe_ports port 21 # ftp acl Safe_ports port 443 # https acl Safe_ports port 70 # gopher acl Safe_ports port 210 # wais acl Safe_ports port 1025-65535 # unregistered ports acl Safe_ports port 280 # http-mgmt acl Safe_ports port 488 # gss-http acl Safe_ports port 591 # filemaker acl Safe_ports port 777 # multiling http acl CONNECT method CONNECT http_access allow manager localhost http_access deny to_localhost include /etc/squid3/acl.conf http_access deny all icp_access deny all htcp_access deny all http_port 3128 hierarchy_stoplist cgi-bin ? access_log /var/log/squid3/access.log squid refresh_pattern ^ftp: 1440 20% 10080 refresh_pattern ^gopher: 1440 0% 1440 refresh_pattern (cgi-bin|?) 0 0% 0 refresh_pattern . 0 20% 4320 icp_port 3130 coredump_dir /var/spool/squid3 include /etc/squid3/misc.conf
ユーザ認証部
/etc/squid3/acl.confで行っている。
認証にはPAMを使用。
PAM認証を通ったものだけHTTPアクセスを認める。
auth_param basic program /usr/lib/squid3/pam_auth auth_param basic children 5 auth_param basic realm Squid proxy-caching web server auth_param basic credentialsttl 2 hours acl password proxy_auth REQUIRED http_access allow password
その他の設定
/etc/squid3/misc.conf
キャッシュを行わないようにする。
また、HTTP_VIA等の出力を抑制して匿名プロキシとして動作させる。
HTTP_ACCEPTをIEのまねっこさせておく。
acl nocache src all no_cache deny nocache header_replace Accept application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/x-shockwave-flash, */* email_err_data off via off forwarded_for off buffered_logs on httpd_suppress_version_string on
こんな感じで認証要求型匿名プロキシができあがり。
ちなみに、認証にはPAM以外もいろいろと利用できる。
debianではsquid3をaptでインストールすると、/usr/lib/squid3以下に認証用のシェルスクリプトやperlスクリプトがおいてある。
squidの認証部分では、それを実行して、ユーザ名とパスワードを入力した返値を参照して認証している。
従って、実際に認証が通るかどうかは実際にたたいて試してみればわかる。
/usr/lib/squid3/pam_auth test password OK
みたいな感じ。