给系统和一些特定软件设定代理
由于一些不得已的缘 故 必须通过代理去访问。
本文整理了一些场景下的代理设置
Linux
一次性设置 这个方法退出后就清除掉了 仅在本次会话内能用
export proxy="http://ip:port"
export http_proxy=$proxy
export https_proxy=$proxy
export ftp_proxy=$proxy
export no_proxy="localhost, 127.0.0.1, ::1"
如果需要持久化配置 写入到 profile里即可。
APT
sudo vim /etc/apt/apt.conf.d/proxy.conf
写入下面的内容
Acquire::http::Proxy "http://user:[email protected]:port/";
Acquire::https::Proxy "http://user:[email protected]:port/";
Snapcraft
sudo snap set system proxy.http="http://192.168.50.97:7890"
sudo snap set system proxy.https="http://192.168.50.97:7890"
yum
vim /etc/yum.conf
写入下面的内容
proxy=http://192.168.5.14:8118
docker
mkdir -p /etc/systemd/system/docker.service.d
vim /etc/systemd/system/docker.service.d/http-proxy.conf
写入下面的内容
[Service]
Environment="HTTP_PROXY=http://192.168.1.2:7890"
Environment="HTTPS_PROXY=http://192.168.1.2:7890"
Environment="NO_PROXY=localhost,127.0.0.1"
重启docker
sudo systemctl daemon-reload
sudo systemctl restart docker
验证
如果Environment打印出刚才设置的proxy 才是设置成功了
systemctl show --property=Environment docker
maven
mvn compile -Dhttps.proxyHost=your_ip -Dhttps.proxyPort=your_port
PIP
pip --proxy=http://192.168.50.97:7890 install divio-cli
Github
方案来自 MeterSphere,但随时都有可能挂掉
- hub.fastgit.org
- ghproxy.com/https://github.com
Git
git config --global http.proxy socks5://127.0.0.1:7890
git config --global https.proxy socks5://127.0.0.1:7890
or
# vim ~/.gitconfig
[http]
proxy = http://127.0.0.1:7890
[https]
proxy = http://127.0.0.1:7890