Menu

SQUIDプロキシサーバのインストール方法

プロキシサーバーを最も早く実行する方法はDocker:

docker run --name squid -p 3128:3128 --rm -d \
  -e PROXYLOGIN=mylogin \
  -e PROXYPASSWORD=mypassword \
  anticaptcha/squid

認証を設定する独自のコンフィギュレーションファイルを設定する場合は、etcsquidsquid.confにマウントします。

docker run --name squid -p 3128:3128 --rm -d \
 -v /path/to/squid.conf:/etc/squid/squid.conf \
anticaptcha/squid

もう一つの方法は、ソースから構築することです

yum -y install make gcc gcc-c++ libtool wget httpd-tools
wget http://www.squid-cache.org/Versions/v3/3.2/squid-3.2.3.tar.gz
tar -zxf squid-3.2.3.tar.gz
cd squid-3.2.3
./configure
make
make install

コンフィギュレーションファイルの例:

#configure the port number
http_port 9191

cache_mem 5 MB
cache_dir ufs /usr/local/squid/var/cache 300 16 256
cache_access_log /usr/local/squid/var/logs/access.log
cache_log /usr/local/squid/var/logs/cache.log
cache_store_log /usr/local/squid/var/logs/store.log
pid_filename /usr/local/squid/var/logs/squid.pid



auth_param basic program /usr/local/squid/libexec/basic_ncsa_auth /usr/local/squid/etc/squid_users

auth_param basic children 5
auth_param basic realm enter_your_pass
auth_param basic credentialsttl 2 hours

error_directory /usr/local/squid/share/errors/


acl SSL_ports port 443
acl Safe_ports port 80 8080 3128 # http
acl Safe_ports port 443# https
acl CONNECT method CONNECT
acl MYUSERS proxy_auth REQUIRED
acl to_ipv6 dst ipv6


http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow net


#allow only athorized users
http_access allow MYUSERS
http_reply_access allow all
icp_access deny all
miss_access allow all


#squid will run under nobody user
cache_effective_user nobody
cache_effective_group nobody
coredump_dir /usr/local/squid/var/cache


## making it anonymous
forwarded_for transparent
request_header_access Via deny all
request_header_access X-Forwarded-For deny all
request_header_access Cache-Control deny all

SQUIDはログインとパスワードを別のファイルに保存します。ここでは"usrlocalsquidetcsquid_users"です。 このファイルを管理するには、"htpasswd"ツールを使用します。

htpasswd -c /usr/local/squid/etc/squid_users mylogin

構成が完了したら、SQUIDディレクトリの権限を変更し、デーモンとして実行します。

chown -R nobody:nobody /usr/local/squid/share /usr/local/squid/var
/usr/local/squid/sbin/squid -z /usr/local/squid/etc/squid.conf
/usr/local/squid/sbin/squid -f /usr/local/squid/etc/squid.conf

プロキシが実行され、接続を受け入れているかどうかを確認します。

netstat -lenp|grep squid

curl -x IP_HERE:3128 -U mylogin:mypassword http://antigate.com/iptest.php