常用命令代理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# --- env
export HTTP_PROXY=127.0.0.1:7897
export HTTPS_PROXY=$HTTP_PROXY
export SOCKS5_PROXY=127.0.0.1:7897
export ALL_PROXY=socks5h://127.0.0.1:7897
# --- curl
curl ip.sb --proxy socks5://127.0.0.1:7897
curl ip.sb --proxy socks5h://127.0.0.1:7897 # remote resolve
# --- wget
wget ip.sb -e "HTTP_PROXY=${HTTP_PROXY}" -e "HTTPS_PROXY=${HTTPS_PROXY}"
# --- apt
# socks5 seems not working
sudo apt -o Acquire::socks::proxy="socks5://${SOCKS5_PROXY}" update
sudo apt -o Acquire::http::proxy="http://${HTTP_PROXY}" update
sudo apt -o Acquire::http::proxy="socks5h://${SOCKS5_PROXY}" update
# --- git
# set
git config --global http.proxy socks5h://${SOCKS5_PROXY}
git config --global https.proxy socks5h://${SOCKS5_PROXY}
# unset
git config --global --unset http.proxy
git config --global --unset https.proxy
# --- docker
mkdir -p /etc/systemd/system/docker.service.d
touch /etc/systemd/system/docker.service.d/http-proxy.conf
cat > /etc/systemd/system/docker.service.d/http-proxy.conf << EOF
[Service]
Environment="HTTP_PROXY=127.0.0.1:7897"
Environment="HTTPS_PROXY=127.0.0.1:7897"
EOF
systemctl daemon-reload
systemctl restart docker
systemctl show --property=Environment docker

# --- pip
# temporary
pip install onnxruntime --proxy="socks5h://10.107.1.101:7890"
# set
pip install pysocks
pip config set global.socks socks5h://10.107.1.101:7890
# unset
pip config set global.proxy None