代理
创建:2023-10-27 17:46
更新:2025-04-19 22:52

全局http/https代理

export ALL_PROXY=socks5://127.0.0.1:1080

# npm 设置代理

# npm ---------- https://registry.npmjs.org/
# yarn --------- https://registry.yarnpkg.com/
# cnpm --------- https://r.cnpmjs.org/
# taobao ------- https://registry.npmmirror.com/

npm set strict-ssl false
npm config set registry https://registry.npm.taobao.org
npm config delete registry
npm --registry=https://registry.npm.taobao.org install

npm config set proxy=http://127.0.0.1:8087
npm config set https-proxy http://server:port
npm config set proxy http://username:password@server:port
npm confit set https-proxy http://username:password@server:port
npm config delete proxy
npm config delete https-proxy

# electron编译
npm config set registry https://registry.npm.taobao.org
npm config set ELECTRON_BUILDER_BINARIES_MIRROR=http://npm.taobao.org/mirrors/electron-builder-binaries/
npm config set ELECTRON_MIRROR=https://npm.taobao.org/mirrors/electron/

# Git代理

git config --global http.proxy 127.0.0.1:7890
git config --global https.proxy 127.0.0.1:7890
git config --global --unset http.proxy
git config --global --unset https.proxy

git config --global http.https://github.com.proxy socks5://127.0.0.1:1080
git config --global --unset http.https://github.com.proxy

git config --global http.proxy #查看git的http代理配置
git config --global https.proxy #查看git的https代理配置
git config --global -l #查看git的所有配置


通过代理网站clone:
git clone https://github.com.cnpmjs.org/mikecao/umami.git
git clone https://gitclone.com/github.com/tendermint/tendermint.git
git config --global url."https://gitclone.com/".insteadOf https://

# go代理

go env -w GOPROXY=https://goproxy.cn,direct
go env -w GOPRIVATE=*.xgjoy.com,*.xgjoy.com
go config --global url."git@github.com:".insteadof "htttps://github.com"

# pip代理

pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

或者设置全局

mkdir -p ~/.pip
echo "[global]" >> ~/.pip/pip.conf
echo "index-url = https://pypi.tuna.tsinghua.edu.cn/simple" >> ~/.pip/pip.conf

# docker代理

https://zhuanlan.zhihu.com/p/24461370776

替代dockerhub搜索: https://dockers.xuanyuan.me/

sudo mkdir -p /etc/docker
sudo vim /etc/docker/daemon.json <<EOF
{
    "registry-mirrors": [
        "https://docker.xuanyuan.me",
        "https://docker.m.daocloud.io",
        "https://docker.1ms.run"
    ]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

手动从代理下载,然后转换tag

docker pull docker.1ms.run/mysql:5.7
docker pull dockerproxy.net/stilleshan/frpc:latest
    docker tag dockerproxy.net/stilleshan/frpc:latest stilleshan/frpc:latest
    docker rmi dockerproxy.net/stilleshan/frpc:latest

使用sock代理

sudo mkdir -p /etc/systemd/system/docker.service.d
# 创建代理配置文件
sudo tee /etc/systemd/system/docker.service.d/http-proxy.conf <<EOF
[Service]
Environment="HTTP_PROXY=socks5://192.168.31.99:7890"
Environment="HTTPS_PROXY=socks5://192.168.31.99:7890"
EOF
# 重新加载配置并重启 Docker
sudo systemctl daemon-reload
sudo systemctl restart docker
# 验证配置生效
sudo systemctl show --property=Environment docker
docker pull ubuntu:22.04