服务端
借助squid实现代理服务
yum install -y squid
vim /etc/squid/squid.conf #默认可以不修改
systemctl restart squid
客户端
物理机
设置http_proxy环境变量
vim /etc/profile
###追加内容
export http_proxy=http://159.226.226.24:3128
export https_proxy=http://159.226.226.24:3128
export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com,10.0.0.0/8,192.168.0.0/16,.local,172.0.0.0/8,istio,.internal"
###
source /etc/profile
Docker
创建目录
mkdir -p /etc/systemd/system/docker.service.d
创建文件/etc/systemd/system/docker.service.d/http-proxy.conf,内容如下:
[Service]
Environment="HTTP_PROXY=http://159.226.226.24:3128"
Environment="HTTPS_PROXY=http://159.226.226.24:3128"
Environment="NO_PROXY=localhost,127.0.0.1,localaddress,.localdomain.com,10.0.0.0/8,192.168.0.0/16,.local,172.0.0.0/8,istio,.internal"
重启Docker
systemctl daemon-reload
systemctl restart docker
验证docker代理是否设置成功
systemctl show --property=Environment docker
#显示如下结果说明设置成功
Environment=GOTRACEBACK=crash HTTP_PROXY=HTTP_PROXY=http://159.226.226.24:3128