linux 下巧妙使用squid代理服务器
一、代理服务器
http_port 192.168.16.1:8080
cache_mem 64 MB
cache_dir ufs /var/spool/squid 4096 16 256
cache_effective_user squid
cache_effective_group squid
dns_nameservers 61.144.56.101
cache_access_log /var/log/squid/access.log
cache_log /var/log/squid/cache.log
cache_store_log /var/log/squid/store.log
visible_hostname 192.168.16.1
cache_mgr lindenstar@163.com
acl all src 0.0.0.0/0.0.0.0
http_access allow all
error_directory /usr/share/squid/errors/Simplify_Chinese
[root@gjp99 ~]# mkdir /mnt/cdrom
[root@gjp99 ~]# mount /dev/cdrom /mnt/cdrom
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@gjp99 Server]# grep -v "^#" /etc/squid/squid.conf |grep -v "^$"
acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl to_localhost dst 127.0.0.0/8
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 localhost
http_access deny all 默认拒绝所有
icp_access allow all
http_port 3128 代理服务器的监听端口,最好在前面写上具体ip地址,
hierarchy_stoplist cgi-bin ?
access_log /var/log/squid/access.log squid
acl QUERY urlpath_regex cgi-bin \?
cache deny QUERY
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern . 0 20% 4320
acl apache rep_header Server ^Apache
broken_vary_encoding allow apache
coredump_dir /var/spool/squid
[root@gjp99 Server]# tail -f /var/log/squid/
access.log cache.log squid.out store.log
[root@gjp99 Server]# tail -f /var/log/squid/access.log
t_search_word_style/piddomain.js - DIRECT/220.181.124.108 application/x-javascript
1346398516.767 17157 192.168.2.22 TCP_MISS/000 0 GET http://www.gougou.com/js/input-ac.js - DIRECT/www.gougou.com -
1346398516.767 17188 192.168.2.22 TCP_HIT/000 0 GET http://www.gougou.com/ - DIRECT/www.gougou.com -
[root@gjp99 ~]# tail -f /var/log/squid/access.log
1346401928.431 2 192.168.2.22 TCP_DENIED/403 1415 GET http://www.baidu.com/ - NONE/- text/html
1346401938.105 1 192.168.2.22 TCP_DENIED/403 1417 GET http://www.google.com/ - NONE/- text/html
1346402102.080 897 192.168.2.21 TCP_MISS/302 934 GET http://www.google.com/ - DIRECT/74.125.71.106 text/html
1346402106.243 4162 192.168.2.21 TCP_MISS/302 648 GET http://www.google.com.hk/url? - DIRECT/74.125.71.199 text/html
1346402109.660 3416 192.168.2.21 TCP_MISS/200 169690 GET http://www.google.com.hk/ - DIRECT/74.125.71.199 text/html
1346402113.359 3596 192.168.2.21 TCP_MISS/404 1310 GEThttp://www.google.com.hk/compressiontest/gzip.html - DIRECT/74.125.71.199 text/html
1346402829.564 4 192.168.2.21 TCP_DENIED/403 1415 GET http://www.baidu.com/ - NONE/- text/html
1346402881.349 2 192.168.2.1 TCP_DENIED/403 1417 GET http://www.gougou.com/ - NONE/- text/html
1346402926.390 2 192.168.2.254 TCP_DENIED/403 1415 GET http://www.baidu.com/ - NONE/- text/html
1346407353.802 12 192.168.2.22 TCP_DENIED/403 1413 GET http://www.sina.com/ - NONE/- text/html
1346407365.210 3 192.168.2.22 TCP_DENIED/403 1415 GET http://news.sina.com/ - NONE/- text/html
acl baddomain1 dstdomain -i www.163.com
http_access deny baddomain1
acl clientip1 src 192.168.2.100
acl conn5 maxconn 5
http_access deny client1 conn1
acl clientnet1 src 192.168.2.0/255.255.255.0
acl worktime time MTWHF 9:00-18:00
http_access deny clientnet1 worktime
[root@gjp99 ~]# date
Fri Aug 31 18:37:49 CST 2012
[root@gjp99 ~]# date 083112302012
Fri Aug 31 12:30:00 CST 2012
1346387408.908 1 192.168.2.22 TCP_DENIED/403 1415 GET http://www.baidu.com/ - NONE/- text/html
acl qq url_regex -i tencent.com
http_access deny qq