index.html

Linux各种杂七杂八代理设置【未完】

字数统计: 288阅读时长: 1 min
2018/11/30 Share

在某些特殊网络环境下用代理访问互联网是很麻烦的,即使在本地开启了代理端口,要让所有的软件都使用代理方法也各不相同。
如果有桌面环境,可以在网络连接设置里添加代理,但至于作用范围有多广就不得而知了。
下面里出一些常用软件的代理设置,以供参考。将不断更新添加。

System Environment Variable

1
2
3
4
5
6
7
8
sudo vi /etc/environment

http_proxy="http://127.0.0.1:8080"
HTTP_PROXY="http://127.0.0.1:8080"
https_proxy="https://127.0.0.1:1081"
HTTPS_PROXY="https://127.0.0.1:1081"
no_proxy="127.0.0.1,localhost,localaddress"
NO_PROXY="127.0.0.1,localhost,localaddress"

Apt

1
2
3
sudo vi /etc/apt/apt.conf.d/90proxy

Acquire::http { Proxy "http://127.0.0.1:8080"; };

Git

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# global proxy
git config --global http.proxy http://user:[email protected]:8080

# URL specific proxy
git config --global http.https://domain.com.proxy http://user:[email protected]:8080
# same effect as above
vi ~/.gitconfig
[http]
[http "https://domain.com"]
proxy = http://user:[email protected]:8080

# unset proxy
git config --global --unset http.proxy
git config --global --unset http.https://domain.com.proxy

Wget

1
2
3
4
5
6
7
8
9
10
11
# global proxy
sudo vi /etc/wgetrc
# user specific proxy
vi ~/.wgetrc

use_proxy=yes
http_proxy=127.0.0.1:8080
https_proxy=127.0.0.1:8080

# onetime usage
wget $URL -e use_proxy=yes -e http_proxy=127.0.0.1:8080

curl

$HTTP_PROXY一致

CATALOG
  1. 1. System Environment Variable
  2. 2. Apt
  3. 3. Git
  4. 4. Wget
  5. 5. curl