版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/kongshuai19900505/article/details/82855739
1.安装squid
[root@localhost ~]# yum install squid -y
安装:
squid.x86_64 7:3.5.20-12.el7.x86_64.rpm
依赖安装:
libecap.x86_64 0:1.0.0-1.el7.x86_64.rpm
perl-Digest-1.17-245.el7.noarch.rpm
perl-Digest-MD5-2.52-3.el7.x86_64.rpm
squid-migration-script-3.5.20-12.el7.x86_64.rpm
2.修改配置文件
[root@localhost ~]# vim /etc/squid/squid.conf
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 localnet src fc00::/7 # RFC 4193 local private network range
acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines
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 deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost manager
http_access deny manager
http_access allow localnet
http_access allow localhost
http_access deny all
http_port 3128
coredump_dir /var/spool/squid
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320
主要是设置端口
http_access deny all
http_port 3128
3.启动服务
[root@localhost ~]# systemctl start squid
查看监听的端口:
[root@localhost cvechecker]# netstat -ntl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
tcp6 0 0 :::111 :::* LISTEN
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 ::1:631 :::* LISTEN
tcp6 0 0 :::3128 :::* LISTEN
tcp6 0 0 ::1:25 :::* LISTEN
可以看到3128端口已经启动
4.关闭防火墙
[root@localhost ~]# systemctl stop firewalld
5.客户端设置
在客户机终端输入:
export http_proxy=http://192.168.13.114:3128
这样就完成了代理,客户机就可以通过本机实现代理上网了