Windows配置 git cmd npm 代理服务
linux的比较简单,直接修改配置文件即可,这里就不再赘述。
git 代理
临时 http 代理
bash
# 地址和端口换成自己的代理服务器
export http_proxy=http://127.0.0.1:7777
export https_proxy=http://127.0.0.1:7777
永久 http 代理
bash
# 命令方式
git config --global http.proxy http://127.0.0.1:50015
git config --global https.proxy http://127.0.0.1:50015
# 修改配置文件方式
# 进入用户名根路径,找到 .gitconfig 文件,修改为
[http]
proxy = http://127.0.0.1:50015
[https]
proxy = http://127.0.0.1:50015
查看 http(s) 代理情况
bash
git config --get --global http.proxy
git config --get --global https.proxy
永久 socks5 代理
bash
命令方式:
git config --global http.proxy socks5://127.0.0.1:50014
git config --global https.proxy socks5://127.0.0.1:50014
修改配置文件方式:
进入用户名根路径,找到 .gitconfig 文件,修改为:
[http]
proxy = socks5://127.0.0.1:50015
[https]
proxy = socks5://127.0.0.1:50015
查看 socks5 代理情况
bash
git config --get --global http.proxy
git config --get --global https.proxy
git config --get --global http.proxy socks5
git config --get --global https.proxy socks5
取消 http 或 socks 代理
bash
git config --system (或 --global 或 --local) --unset http.proxy
例:
git config --global --unset http.proxy
git config --global --unset https.proxy
cmd 代理
cmd http 代理
bash
# cmd临时代理方案(cmd窗口关闭,则代理失效)
set http_proxy=http://127.0.0.1:50015
set https_proxy=http://127.0.0.1:50015
# cmd永久代理方案
netsh winhttp import proxy source=ie
cmd socks5 代理
bash
set http_proxy=socks5://127.0.0.1:50014
set https_proxy=socks5://127.0.0.1:50014
cmd (服务器)针对性代理,绕过本地请求(修改为自己的代理地址和端口)
bash
# http
netsh winhttp set proxy proxy-server="http=192.168.17.100:50015" bypass-list="localhost"
# https
netsh winhttp set proxy proxy-server="http=192.168.17.100:50015" bypass-list="localhost"
# socks
netsh winhttp set proxy proxy-server="socks=192.168.17.100:50015" bypass-list="localhost"
cmd 查看代理情况
bash
netsh winhttp show proxy
cmd 取消代理情况
bash
netsh winhttp reset proxy
npm 代理设置
bash
# 设置http代理
npm config set proxy=http://代理服务器地址:8080
# 取消代理
npm config delete proxy
# npm设置淘宝镜像
npm config set registry=https://registry.npm.taobao.org
# npm取消淘宝镜像
npm config delete registry
# 查看代理信息(当前配置)
npm config list