Centos7使用squid实现正向代理
正向代理:代理服务器帮助客户端(浏览器)实现互联网的访问
环境:centos7.5
client: 192.168.1.250(私网)
squid代理:192.168.1.242(私网)
139.9.218.xx (公网)
(1)代理服务器配置
1.安装squid
[root@squid ~]# yum install squid -y
2.编辑squid配置文件
[root@squid ~]# vim /etc/squid/squid.conf
acl local src 192.168.1.0/24 //允许192.168.1.0/24网段内所有客户机访问代理服务器
http_access allow local //该记录一定要添在deny all之前
http_port 3128
- 防火墙配置
[root@squid ~]# systemctl stop firewalld
[root@squid ~]# systemctl disable firewald
##安装iptables
[root@squid ~]# yum install iptables-services iptables-devel -y
[root@squid ~]# systemctl enable iptables.service
[root@squid ~]# systemctl start iptables.service
##添加策略
[root@squid ~]# iptables -I INPUT 1 -s 192.168.1.0/24 -p tcp –dport 3128 -j ACCEPT
[root@squid ~]# iptables -I INPUT 2 -p tcp –dport 3128 -j DROP
4.启动squid服务
[root@squid ~]# systemctl start squid
[root@squid ~]# systemctl enable squid
(2)linux客户端配置
1.linux客户端配置正向代理
[root@squid ~]# export http_proxy=http://192.168.1.242:3128 ##192.168.1.242是代理服务器私网ip
[root@squid ~]# echo “export http_proxy=http://192.168.1.242:3128” >> /etc/profile
- 测试http:
[root@squid ~]# wget http://www.cmake.org/files/v3.3/cmake-3.3.1.tar.gz
(3)windows客户端设置,以搜狗浏览器演示
暂无评论内容