squid 簡單配置

tonykorn97發表於2008-10-20

配置squid讓同網段內的其他機器可以使用

一,安裝:
[root@station10 ~]# yum -y install squid

[@more@]


二,啟動預設配置:
[root@station10 ~]# chkconfig squid on
[root@station10 ~]# service squid start
Starting squid: .[ OK ]
[root@station10 ~]#


三,預設的配置資訊:
http_port 3128
hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin ?
cache deny QUERY
acl apache rep_header Server ^Apache
broken_vary_encoding allow apache
access_log /var/log/squid/access.log squid
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern . 0 20% 4320
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 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
http_reply_access allow all
icp_access allow all
coredump_dir /var/spool/squid


四,檢視訪問的資訊:
[root@station10 ~]# tail -f /var/log/squid/access.log
1224506740.327 354 127.0.0.1 TCP_REFRESH_HIT/304 307 GET http://192.168.0.10/ - DIRECT/192.168.0.10 -
1224506746.019 44 192.168.0.12 TCP_DENIED/403 1452 GET - NONE/- text/html

本機可以訪問,其他機器不能訪問

五,設定iptables
[root@station10 ~]# iptables -I INPUT -s 192.168.0.0/24 -p tcp --dport 3128 -j ACCEPT
[root@station10 ~]# service iptables save
Saving firewall rules to /etc/sysconfig/iptables: [ OK ]
[root@station10 ~]# iptables --list
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- 192.168.0.0/24 anywhere tcp dpt:squid

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

Chain RH-Firewall-1-INPUT (0 references)
target prot opt source destination
[root@station10 ~]#

六, 編輯squid檔案,讓同子網內可以使用

1,在acl CONNECT method CONNECT下面新增:
acl example src 192.168.0.0/24

2,在# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS行下面新增:
http_access allow example

3,重新匯入配置:
[root@station10 squid]# service squid reload
[root@station10 squid]#


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/312079/viewspace-1012148/,如需轉載,請註明出處,否則將追究法律責任。

相關文章