Squid代理服務器 、 ACL訪問控制列表
#####################################
-------------------------------
客戶主機:192.168.4.100 eth0
-------------------------------
代理主機:192.168.4.5 eth0
192.168.2.5 eth1
------------------------------
Web主機: 192.168.2.100 eth1
--------------------------------
Squid服務端:
軟件包:squid-3.1-10-19.el6_4.x86_64
系統服務:squid
主程序:/usr/sbin/squid
主配置文件:/etc/squid/squid.conf
默認監聽端口:TCP 3128
默認訪問日誌:/var/log/squid/access.log
一,Squid代理服務器:(192.168.2.5/192.168.4.5)
1,安裝軟件包
#yum -y install squid
2,修改配置文件
#vim /etc/squid/squid.conf
51:http_access deny all訪問控制
修改爲:http_access allow all
62:visible_hostname proxy.xxx.con 主機名
64:http_port 3128 端口
修改爲:80
65:cache_dir ufs /var/spool/squid 100 16 256
緩存,緩存目錄爲/var/spool/squid
緩存大小爲100M
一級目錄爲16個,二級目錄256個
#service squid start #啓動squid服務
#netstat -anptu | grep squid
#ls /var/spool/squid
3,Web主機(192.168.2.100)
#yum -y install httpd
#echo "test" > /var/www/html/index.html
#service httpd start
4,客戶端驗證(192.168.4.100)
#curl http://192.168.2.100 失敗
#curl --proxy1.0 192.168.4.5:3128 http://192.168.2.100/ 成功
代理設置:
#firefox-->alt鍵---編輯--首選項---高級---網絡--設置--》代理IP和端口
5,在代理服務器上查看日誌
#tail /var/log/squid/access.log
6,在web服務器上查看日誌
#tail /var/log/httpd/access_log
++++++++++++++++++++++++++++++++++++++
反向代理
1.代理設置:
#vim /etc/squid/squid.conf
62:http_port 80 vhost
63:cache_peer 192.168.2.100 parent 80 0 originserver
#service squid restart
++++++++++++++++++++++++++++++++++++++++++
客戶端驗證:
#curl http://192.168.2.100 失敗
#curl http://192.168.4.5 成功
#######################################
++++++++++++++++++++++++++++++++++++++
#######################################
Squid訪問控制ACL
先定義ACL:
acl 列表名稱 列表類型 列表內容...
調用ACL:
http_access allow 列表名稱...
http_access deny 列表名稱...
常用的ACL列表類型:
src 源地址
dst 目標地址
port 目標端口
dstdomain 目標域
time 訪問時間
maxconn 最大併發鏈接
url_regex 目標URL地址 {支持正則表達式}
urlpath_regex 整個目標URL路徑 {支持正則表達式}
################################################
定義:
acl 名稱 類型 內容
acl abc time 17:00-18:00
acl qq src 192.168.4.100
acl aaa src 0.0.0.0/0.0.0.0
調用:
http_access allow|deny 名稱
http_access allow abc
http_access deny qq
http_access deny aaa
++++++++++++++++++++++++++++++++++++
#vim /etc/squid/squid.conf
acl myip src 192.168.4.254
http_access deny myip
acl mytime time MTWHF 00:00-18:00
http_access deny mytime
#注意寫在別的規則上面
#service squid restart
栗子:
acl myip src 192.168.4.5
acl
http_access allow mynet mytime
http_access allow myip
http_access deny all
未設置任何規則時,拒絕所有訪問請求
已設置規則時,依次進行檢查,找到匹配即停止,否則採用與最後一條規則相反的權限ip2 src 192.168.4.10
acl mynet src 192.168.4.0/24
acl mytime time MTWHF 09:00-18:00
http_access allow mynet mytime
http_access allow myip
http_access deny all
未設置任何規則時,拒絕所有訪問請求
已設置規則時,依次進行檢查,找到匹配即停止,否則採用與最後一條規則相反的權限
Squid代理服務器
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
bat記錄遠程桌面連接登錄信息
jason1982
2019-02-24 12:57:09
Exchange Server 2010 POP3&IMAP設置詳解
lingping
2019-02-23 14:05:54
虛擬化技術--服務器虛擬化
dawei818
2019-02-23 14:05:39
windows 2008 全新仲裁模式
qyh282110204
2019-02-23 14:05:36
軟路由建立PPPOE服務器
ct19871125
2019-02-23 14:04:24
MySQL性能優化的21個最佳實踐
fdb2b
2019-02-23 14:01:03
centos下簡單實現日誌切割,並上傳至日誌服務器。
隨風上升
2019-02-23 13:59:02
iscsi存儲
samplelife
2019-02-23 13:57:35
Nagios 3.2 監控部署(一)
samplelife
2019-02-23 13:57:35
50元打造雙網卡負載均衡服務器
138web
2019-02-23 13:55:58
網絡打印機的一般故障
zhongqijian916
2019-02-23 13:54:50