web的流量可以通过proxy设置(但是只能浏览器代理访问,terminal等不行,那怎么办?往下看)
- 一般这样查看windows
或者CMD/powershell命令,可以设置:
set http_proxy=http://proxy.com:port/
set http_proxy_user=username
set http_proxy_pass=password
或者
set http_proxy=http://127.0.0.1:7777
set https_proxy=http://127.0.0.1:7777
但是,如果是git bash需要用linux命令
export http_proxy=http://127.0.0.1:7777
export https_proxy=http://127.0.0.1:7777
之后就可以通过代理访问网络了。不过以上是临时的,关闭cmd窗口则代理消失,如果取消则是:
netsh winhttp reset proxy
或者
set http_proxy=
set https_proxy=
如果不想每次都设置,可以将这些环境变量,设置到系统的环境变量中。右击我的电脑–>属性–>高级–>环境变量–>系统变量,用新建的方式去设置代理服务器。
验证:
curl www.google.com
- 如果只在代码层面访问怎么办,只需设置request代理,如下
或者axios
- 如果是git命令怎么办?
- nodejs
const creds = require("./key.json");
process.env.HTTP_PROXY='http://127.0.0.1:3213' ;
process.env.HTTPS_PROXY='http://127.0.0.1:3213' ;