Centos7安装Squid的配置透明代理是怎样的
.
Centos7安装Squid的配置透明代理是怎样的?
Squid是一个开源的代理服务器,可以用来进行透明代理。透明代理的配置方法如下:
1.安装Squid
yum install squid
2.修改Squid配置文件
vim /etc/squid/squid.conf
修改如下内容:
http_port 3128
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
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 localnet
http_access allow localhost
http_access deny all
3.启动Squid
systemctl start squid
4.开机自启动
systemctl enable squid
5.查看Squid状态
systemctl status squid
6.修改防火墙
vim /etc/sysconfig/iptables
增加如下内容:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3128 -j ACCEPT
7.重启防火墙
systemctl restart iptables
8.配置客户端
vim /etc/profile
在最后增加如下内容:
export http_proxy=http://10.0.0.1:3128
export https_proxy=http://10.0.0.1:3128
9.使配置文件生效
source /etc/profile
10.查看代理是否设置成功
curl -I www.baidu.com
如果返回结果中包含“Via: 1.1 proxy.example.com:3128 (Squid/3.5.12)”,则表示代理设置成功。
相关文章