本文档中192.168.137.1是代理服务器,10809是http代理端口,10808是socket代理端口
系统代理
临时添加
export http_proxy="http://192.168.137.1:10809"
export https_proxy="http://192.168.137.1:10809"
永久添加
echo 'export http_proxy="http://192.168.137.1:10809"' >> /etc/profile
echo 'export https_proxy="http://192.168.137.1:10809"' >> /etc/profile
git的代理添加
git config --global http.proxy socks5://192.168.137.1:10808
git config --global https.proxy socks5://192.168.137.1:10808
docker的代理添加
cat > /etc/systemd/system/docker.service.d/proxy.conf << EOF
[Service]
Environment="HTTP_PROXY=http://192.168.137.1:10809"
Environment="HTTPS_PROXY=http://192.168.137.1:10809"
EOF
systemctl daemon-reload && systemctl restart docker
systemctl show --property=Environment docker # 查看参数是否生效
containerd代理添加
mkdir -p /etc/systemd/system/containerd.service.d
touch /etc/systemd/system/containerd.service.d/http-proxy.conf
tee /etc/systemd/system/containerd.service.d/http-proxy.conf << EOF
[Service]
Environment="HTTP_PROXY=http://192.168.137.1:10809"
Environment="HTTPS_PROXY=http://192.168.137.1:10809"
Environment="NO_PROXY=localhost,127.0.0.1,containerd"
EOF
systemctl daemon-reload
systemctl restart containerd
podman添加代理
mkdir -p /etc/systemd/system/podman.service.d
tee /etc/systemd/system/podman.service.d/http-proxy.conf << EOF
[Service]
Environment="HTTP_PROXY=http://192.168.137.1:10809"
Environment="HTTPS_PROXY=http://192.168.137.1:10809"
Environment="NO_PROXY=localhost,127.0.0.1"
EOF
systemctl daemon-reload
systemctl restart podman