squid+ziproxyで圧縮プロキシサーバーを構築する
割と良くある話だが、やってみると色々躓きポイントが有ったので整理してみよう。
やりたいこと
モバイル回線が重たいので、インターネット上のVPSにプロキシサーバーを構築したい。
プロキシは2段構えとする。
構成
(1)クライアント-—>インターネット-—>ziproxy+squid-—>接続先
(2)クライアント-—->インターネット-–>squid-—>接続先
接続方法は2つ考えた。(1)に関しては圧縮も聞かせたい場合。(2)に関しては単なるキャッシュサーバーとして使いたい場合。
現在の主回線がポケットWiFIなので、キャッシュサーバーとしても割と十分機能するのである。
##環境
Ubuntu 16.04LTS
install
apt-get install squid ziproxy
コンフィグ
/etc/squid.squid.conf
acl allok src 0.0.0.0/0.0.0.0
acl localhost src 127.0.0.1/32
acl all src all
acl SSL_ports port 443
acl Safe_ports port 80
acl Safe_ports port 21
acl Safe_ports port 443
acl Safe_ports port 70
acl Safe_ports port 210
acl Safe_ports port 1025-65535
acl Safe_ports port 280
acl Safe_ports port 488
acl Safe_ports port 591
acl Safe_ports port 777
acl CONNECT method CONNECT
###################digest###################
auth_param digest program /usr/lib/squid3/digest_file_auth /etc/squid/passwd
auth_param digest children 3
auth_param digest realm Proxy Web Server
auth_param digest nonce_garbage_interval 5 minutes
auth_param digest nonce_max_duration 30 minutes
auth_param digest nonce_max_count 50
acl password proxy_auth REQUIRED
#http_access allow localnet #コメントにする。
http_access allow password
###########################################################
http_access allow manager localhost
http_access allow all
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost
http_access allow localnet
http_access allow localnet2
http_access deny all
/etc/ziproxy/ziproxy.conf
Port = 7777
Address = “AAA.BBB.CCC.DDD” #鯖のグローバルIP
TransparentProxy = true
UseContentLength = false
ImageQuality = {10,10,10,10}
#ProcessToJP2 = true
#JP2ImageQuality = {20,20,20,17}
NextProxy=“127.0.0.1”
NextPort=9080
ErrorLog ="/var/log/ziproxy/error.log"