因为有些服务器是没有公网IP,这些服务器要访问公网资源,就需要在有公网 IP 的服务器上搭建一个代理服务器,然后再配置内网服务器,通过代理获取公网资源。
这里使用 squid 做代理服务,安装,启动,设置开机自动启动:
[root@localhost ~]# yum -y install squid
[root@localhost ~]# systemctl enable squid
[root@localhost ~]# systemctl start squid
squid 的默认端口是 3128
编辑 /etc/profile
在末尾加上以下内容
http_proxy=192.168.0.57:3128
https_proxy=$http_proxy
no_proxy=192.168.0.*,localhost,127.0.0.1
export http_proxy https_proxy no_proxy
应用配置
[root@localhost ~]# source /etc/profile
参考: