各种环境设置代理

一,git

支持socks5或者http代理

  • 全局代理

    1
    2
    git config --global http.proxy socks5://ip:port
    git config --global https.proxy socks5://ip:port
  • 指定github设置代理

    1
    git config --global http.https://github.com.proxy http://ip:port

二,docker

1
2
3
4
5
6
7
8
9
$ sudo vim /etc/docker/daemon.json 
{
"proxies": {
"http-proxy": "http://ip:port",
"https-proxy": "http://ip:port",
"no-proxy": "*.test.example.com,.example.org,127.0.0.0/8"
}
}
sudo systemctl restart docker

三,apt

1
2
3
4
# cat >> /etc/apt/apt.conf << EOF
Acquire::http::Proxy "http://ip:port/";
Acquire::ftp::Proxy "ftp://ip:port/";
EOF

四,android

1
2
adb shell settings put global http_proxy ip:port
adb shell settings put global https_proxy ip:port

五,wget/curl

  • wget

    1
    2
    wget -e use_proxy=yes -e https_proxy=http://ip:port https://example.com
    wget -e use_proxy=yes -e https_proxy=socks5://ip:port https://example.com
  • curl

    1
    2
    curl -x http://ip:port https://example.com
    curl -x socks5://ip:port https://example.com

六,bashrc设置代理脚本

  • 在.bashrc中添加以下代码,要使用时在终端执行setproxy或者setproxy socks5命令
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    function setproxy {
    echo "set proxy"
    if [[ $1 == "del" ]]; then
    unset http_proxy
    unset https_proxy
    unset all_proxy
    unset ALL_PROXY
    elif [[ $1 == "socks5" ]]; then
    echo "set socks5 proxy"
    export all_proxy=socks5://ip:port
    export ALL_PROXY=socks5://ip:port
    else
    export http_proxy=http://ip:port
    export https_proxy=http://ip:port
    fi
    echo http_proxy=$http_proxy
    echo https_proxy=$https_proxy
    echo all_proxy=$all_proxy
    echo ALL_PROXY=$ALL_PROXY
    }

各种环境设置代理
https://hqw700.github.io/2025/09/29/2025-09-29-some-env-proxy-setting/
发布于
2025年9月29日
许可协议