proxyサーバ squidでアクセス時に認証を要求する設定(Ubuntu14.04の設定)

スポンサーリンク
スポンサーリンク

Ubuntu14.04で Proxyサーバ squidで、digest認証でユーザ名/パスワードを要求するようにする設定ファイルです。

CentOS6 については、下記を参照して下さい。basic認証も説明しています。

proxyサーバ squidでアクセス時に認証を要求する設定 パソコン鳥のブログ

設定

インストールします。

apt-get install squid

パスワードファイルの作成

htpasswd -cp /etc/squid3/passwd ユーザ名

実行後、パスワードの入力を求められますので、入力します。
/etc/squid3/passwd ファイルには、パスワードがそのまま記述されますので、注意!

squid.conf に設定を行います。

http_port でsquidで使用するポート番号を指定します。下記例では 8080番です。
acl localnet src で、squidに接続できるIPアドレスを指定します。

/etc/squid3/squid.conf

auth_param digest program /usr/lib/squid3/digest_file_auth /etc/squid3/passwd
auth_param digest children 20 startup=0 idle=1
auth_param digest realm proxy
auth_param digest nonce_garbage_interval 5 minutes
auth_param digest nonce_max_duration 30 minutes
auth_param digest nonce_max_count 50
acl pauth proxy_auth REQUIRED
http_access allow pauth
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1
acl localnet src XX.XX.XX.0/24
acl localnet src YY.YY.YY.YY
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 manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localnet
http_access allow localhost
http_access deny all
hierarchy_stoplist cgi-bin ?
coredump_dir /var/spool/squid3
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern (Release|Packages(.gz)*)$      0       20%     2880
refresh_pattern . 0 20% 4320
http_port 8080
cache_mem 32 MB
cache_dir ufs /var/spool/squid3 4000 16 256
maximum_object_size 65536 KB
forwarded_for off
request_header_access Referer deny all
request_header_access X-Forwarded-For deny all
request_header_access Via deny all
request_header_access Cache-Control deny all
access_log /var/log/squid3/access.log common 
cache_effective_user proxy

設定に不備が無いかチェックします。
下記コマンド実行で、ERROR と出力されなければ OK です。

squid3 -k parse

squidを起動します。

service squid3 start

これで、Ubuntu14.04の squidで、digest認証でユーザ名/パスワードを要求するようにできます。

参考

Re: Re: [squid-users] "emulate_httpd_log on" is not working from Henrik Nordström on 2010-03-16 (squid-users)

Ubuntu忘備録: squid3プロキシサーバの設定(Ubuntu13.10)

コメント

タイトルとURLをコピーしました