Linux · 18 3 月, 2021 0

CentOS常见应用代理设置方法

CentOS常见应用代理设置方法

  1. 系统代理
    编辑/etc/profile,追加如下内容:
export ALL_PROXY="https://username:password@proxy_ip:port"

然后执行source /etc/profile

  1. Yum
    编辑/etc/yum.conf,追加如下内容:
proxy=xxx.proxy.com
proxy_username=username
proxy_password=password
# 注意每行前面千万不能留空格。2021.08.27
  1. Docker
  • 创建目录mkdir /etc/systemd/system/docker.service.d
  • 添加地址
cd /etc/systemd/system/docker.service.d
cat >/etc/systemd/system/docker.service.d/http_proxy.conf << EOF
[Service]
Environment="HTTP_PROXY=http://192.168.1.1:80/"
Environment="HTTPS_PROXY=http://192.168.1.1:80/"
Environment="NO_PROXY=localhost,127.0.0.0/8,docker-registry.somecorporation.com"
EOF
  • 重启服务
systemctl daemon-reload
systemctl restart docker
  1. Pypi
pip install --proxy http://username:password@proxy_ip:proxy_port module_name
  1. Wget
    在/etc/wgetrc里,取消掉下文注释并加入需要的内容:
http_proxy=http://<user>:<pwd>@<host>:<port>
  1. Git
# 设置代理
git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
git config --global http.proxy socks5://127.0.0.1:1080
git config --global https.proxy socks5://127.0.0.1:1080
# 取消设置
git config --global --unset http.proxy
git config --global --unset https.proxy