CentOS 搭建代理服务器,设置代理获取数据 (1780 views)

gHOST

2019-06-24 11:25:35

因为有些服务器是没有公网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

参考: