1. 程式人生 > >Centos 7 squid實現正向代理

Centos 7 squid實現正向代理

轉自https://www.cnblogs.com/lovelinux199075/p/9062345.html

正向代理:代理伺服器幫助客戶端(瀏覽器)實現網際網路的訪問

(1)代理伺服器配置

1.安裝squid

yum install squid -y 

2.編輯squid配置檔案

#vim /etc/squid/squid.conf 
acl local src 192.9.191.0/24       //允許192.9.191.0/24網段內所有客戶機訪問代理伺服器
http_access allow localnet        //該記錄一定要添在deny all之前
http_port 3128 



3.防火牆配置

systemctl stop firewald.service 
systemctl disable firewald.service
yum install iptables-services iptables-devel -y
systemctl enable iptables.service
systemctl start iptables.service
iptables -I INPUT 1 -s 192.9.191.0/24 -p tcp --dport 3128 -j ACCEPT
iptables -I INPUT  2 -p tcp --dport 3128 -j DROP 

4.啟動squid服務

systemctl start squid 
systemctl enable squid 

(2)linux客戶端配置

1.linux客戶端配置正向代理

export http_proxy=http://192.9.191.30:3128          \\192.9.191.30是代理伺服器ip
export https_proxy=http://192.9.191.30:3128
echo "export http_proxy=http://192.9.191.30:3128" >>/etc/profile
echo "export https_proxy=http://192.9.191.30:3128" >>/etc/profile

2.測試http

  wget http://www.cmake.org/files/v3.3/cmake-3.3.1.tar.gz

3.代理伺服器上檢視日誌/var/log/squid/access.log

4.測試https

wget https://codeload.github.com/gflags/gflags/tar.gz/v2.1.2

5.在代理伺服器上檢視日誌/var/log/squid/access.log

(3)windows客戶端設定,以搜狗瀏覽器演示


測試http和https檢視日誌