一寸前のsquid設定を。
今はこれよりもっと書いてしまっているが、収拾が付かなくなりそうなので一度上げとこうかと。
透過プロキシで、httpアクセラレーター設定。
iptablesでポートの転送設定しないといつまでも繋がらないので注意。
あとhttps(ssl通信)をsquidで乗っ取ろうとしたけど断念。
理由は透過プロキシだとman inthe middleになってしまうので、sslbumpを入れないといけなくなる(入れたら入れたで、証明書が違うと警告がユーザークライアントに多発するので現実的では無いという判断)。
結局iptablesで、どうしてもはじきたい所をはじくという、苦肉の策になる。
どうにかならないものかなあ・・。
http://roserogue.blogspot.jp/2014/12/1e100netgoogle.html
を参照のこと。
#squid3
#
#
http://squid.robata.org/
#が一番情報載ってる
#
# Recommended minimum configuration:
# ここら辺はデフォルト設定をそのまま
#
#acl cache object localhost
acl manager proto cache_object
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 ipv4local address ipv6 local unicast address
# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl localnet src fc00::/7 # RFC 4193 local private network range
acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines
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
#
# Recommended minimum Access Permission configuration:
#
# Only allow cachemgr access from localhost
http_access allow manager localhost
http_access deny manager
# Deny requests to certain unsafe ports
http_access deny !Safe_ports
# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports
# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost
#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#
# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
#user user
cache_effective_user squid
cache_effective_group squid
###########################################
#user blacklist
###########################################
#接続させたくないURL、IPアドレス、URLパス
#
#dstdomain ドメイン名を正規表現で表記。ドットから始めればサブドメインも含まれる
#ダブルクォーテーションでくくってファイル参照
#regex
#path
#user blacklist
acl blacklist dstdomain "/etc/squid/blacklist"
acl blacklist_regex url_regex "/etc/squid/blacklist_regex"
acl blackpath urlpath_regex -i "/etc/squid/blackpath"
#blacklist deny list
http_access deny blacklist
http_access deny blacklist_regex
http_access deny blackpath
###########################################
#deny user
###########################################
#接続させたくない特定のユーザー(クライアント)を指定。ローカルIPアドレスで指定する。
acl deny_userlist src "/etc/squid/userlist_deny"
#acl deny_userlist src 192.168.1.255 192.168.1.254
http_access deny deny_userlist
###########################################
#limit user
###########################################
#限定的に接続させたい任意のユーザー(クライアント)を指定。ローカルIPで指定する。
acl limit_userlist src "/etc/squid/userlist_limit"
acl limit_domain_url dstdomain "/etc/squid/url_limit_domain"
acl limit_regex_url url_regex "/etc/squid/url_limit_regex"
http_access allow limit_userlist limit_domain_url
http_access allow limit_userlist limit_regex_url
http_access deny limit_userlist
###########################################
#特定URL等。遅延プール
###########################################
#http://www.itmedia.co.jp/enterprise/articles/0812/01/news024_2.html
#acl peakperiod time 10:00-16:00
#Delay_Pool
delay_pools 3
#-----------pool 1 ----------------
#userlist_delayの中のIPアドレスユーザーを遅延させる
delay_class 1 1 # pool 1 is a class 1 pool
acl delay_userlist src "/etc/squid/userlist_delay"
#
# SPEED
delay_parameters 1 320/320
#
delay_access 1 allow delay_userlist
delay_access 1 deny all
#-----------pool 2 ----------------
#リストに表記されているURLなどへのアクセスを遅延させる
delay_class 2 1 # pool 1 is a class 1 pool
acl dstdelaylist dstdomain "/etc/squid/delaylistdst"
acl regex_delaylist url_regex "/etc/squid/delaylist_regex"
acl pathdelaylist urlpath_regex -i "/etc/squid/delaylistpath"
#1408kbit/s
delay_parameters 2 176000/176000
#896kbit/s
#delay_parameters 2 112000/112000
# 64 Kbit/s
#delay_parameters 2 8000/8000
delay_access 2 allow dstdelaylist
delay_access 2 allow regex_delaylist
delay_access 2 allow pathdelaylist
delay_access 2 deny all
#-----------pool 3 ----------------
#特定のブラウザ使用者を遅延させる
delay_class 3 1 # pool 1 is a class 1 pool
acl delaybrowser browser -i Chrome
acl delaybrowser browser -i Safari
# 128 Kbit/s
delay_parameters 3 16000/16000
delay_access 3 allow delaybrowser
delay_access 3 deny all
#----------delaypool end------------------#
###########################################
#user FTP
###########################################
acl FTP proto FTP
always_direct allow FTP
###########################################
#最終許可
###########################################
http_access allow localnet
http_access allow localhost
# And finally deny all other access to this proxy
http_access deny all
######################################################################################
###########################################
# Squid normally listens to port 3128
#user
#http_port 3246
http_port 3246 transparent
#http_port 3128 transparent
#http_port 3128
# We recommend you to use at least the following line.
hierarchy_stoplist cgi-bin ?
#--------------------------
# Uncomment and adjust the following to add a disk cache directory.
#cache_dir ufs /var/spool/squid 100 16 256
#user
#cache_dir 32GB
cache_dir aufs /var/spool/squid/cache_l 32768 16 256
#maximum_object_size 128MB
maximum_object_size 131072 KB
#cache_mem 1GB(total 3GB or so)
cache_mem 1024 MB
memory_pools_limit 0
# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid
#--------------------------------
# Add any of your own refresh_pattern entries above these.
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
#refresh_pattern . 0 20% 4320
##################################
#USER ADD REFRESH PATTERN
##################################
refresh_pattern -i \.(gif|png|jpg|jpeg|ico)$ 10080 80% 43200 override-expire ignore-no-cache ignore-no-store ignore-private
refresh_pattern -i \.(iso|avi|wav|mp3|mp4|mpeg|3gp|swf|flv|x-flv)$ 43200 90% 432000 override-expire ignore-no-cache ignore-no-store ignore-private
refresh_pattern -i \.(deb|rpm|exe|msi)$ 10080 90% 43200 override-expire ignore-no-cache ignore-no-store ignore-private
refresh_pattern -i \.index.(html|htm)$ 0 40% 10080
refresh_pattern -i \.(html|htm|css|js)$ 1440 40% 40320
refresh_pattern . 0 40% 40320
##################################
#user
#LOG
logfile_rotate 14
cache_access_log /var/log/squid/access.log
cache_log /var/log/squid/cache.log
cache_store_log /var/log/squid/store.log
access_log /var/log/squid/access.log
#user
#auth_param basic program
auth_param basic children 10
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 2 hours
auth_param basic casesensitive off
#user
pipeline_prefetch on
###########################################
#user anonymize
###########################################
icp_port 0
forwarded_for off
client_db off
#user HEADER ANONYMIZING
#header_accessは30系で無くなったらしい
request_header_access X-Forwarded-For deny all
request_header_access Via deny all
request_header_access Cache-Control deny all
###########################################
#SQUID3 HEADER REPLACE###
###########################################
request_header_access From deny all
request_header_access Referer deny all
request_header_access User-Agent deny all
header_replace User-Agent Mozilla/5.5 (Windows NT 55.0; Win64; x64) AppleWebKit/555.55 (KHTML, like Gecko) Chrome/55.0.0005.05 Safari/555.55 Edge/15.0
#user
visible_hostname none
#header_replace Referer google.com