记录Linux下各种常见的代理配置方式

npm 代理

设置

npm config set proxy http://127.0.0.1:7890
npm config set https-proxy http://127.0.0.1:7890

取消

npm config delete proxy
npm config delete https-proxy

查看

npm config list

wget

写入文件 ~/.wgetrc,删除代理注释代码行即可

#You can set the default proxies for Wget to use for http, https, and ftp.
# They will override the value in the environment.
https_proxy = http://127.0.0.1:7890/
http_proxy = http://127.0.0.1:7890/
If you do not want to use proxy at all, set this to off.use_proxy = on

Terminal代理

设置

export http_proxy=http://127.0.0.1:7890
export https_proxy=http://127.0.0.1:7890

取消

unset http_proxy
unset https_proxy

Git代理

全局代理

git config –-global http.proxy http://127.0.0.1:7890
git config –-global https.proxy http://127.0.0.1:7890

查看代理

git config --global --get http.proxy
git config --global --get https.proxy
# 列出所有配置
git config --global --list

取消代理

git config --global --unset http.proxy
git config --global --unset https.proxy

为某一个仓库配置代理

比如只让github走代理

git config --global http.https://github.com.proxy http://127.0.0.1:7890
git config --global https.https://github.com.proxy https://127.0.0.1:7890

Gradle代理

gadle全局代理,修改 ~/.gradle/gradle.properties文件 添加代理字段:

  systemProp.http.proxyHost=127.0.0.1
  systemProp.http.proxyPort=7890
  systemProp.https.proxyHost=127.0.0.1
  systemProp.https.proxyPort=7890

如果要取消代理,注释上面的代码即可

Ubuntu apt代理

编辑配置文件 vim /etc/apt/apt.conf.d/proxy.conf
添加

Acquire::http::Proxy "http://[username]:[password]@ [proxy-web-or-IP-address]:[port-number]";
Acquire::https::Proxy "http://[username]:[password]@ [proxy-web-or-IP-address]:[port-number]";
Acquire::http::Proxy "http://127.0.0.1:7890"

Acquire::https::Proxy "http://127.0.0.1:7890"

SSH代理

github ssh代理

vim ~/.ssh/config

Host github.com
    ProxyCommand nc -x 127.0.0.1:7890 %h %p

春风花气馥,秋月寒江湛