假设代理为:
sockts5 127.0.0.1:1080
http 127.0.0.1:1081
配置:
打开cmd窗口:
输入以下命令,即可设置好代理.
//使用http代理
set http_proxy=http://127.0.0.1:1081
set http_proxys=http://127.0.0.1:1081
//使用sockts5代理
set http_proxy=socks5://127.0.0.1:1080
set https_proxy=socks5://127.0.0.1:1080
验证是否添加成功了代理,不能用ping命令,因为ping命令的协议不是HTTP,也不是HTTPS,而是ICMP协议。
curl -vv http://www.google.com
C:\Users\soft>curl -vv http://www.google.com
* Rebuilt URL to: http://www.google.com/
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 1081 (#0)
> GET http://www.google.com/ HTTP/1.1
> Host: www.google.com
> User-Agent: curl/7.55.1
> Accept: */*
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 OK
< Date: Sun, 15 Nov 2020 08:17:26 GMT
< Expires: -1
< Cache-Control: private, max-age=0
< Content-Type: text/html; charset=ISO-8859-1
< P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
< Server: gws
< X-XSS-Protection: 0
< X-Frame-Options: SAMEORIGIN
< Set-Cookie: 1P_JAR=2020-11-15-08; expires=Tue, 15-Dec-2020 08:17:26 GMT; path=/; domain=.google.com; Secure
< Set-Cookie: NID=204=eYK_XEuhJZ4_2E_x6UBK7pltLZ2-6NM8AKFJkoIokIBwaooaDo0D-iVtKV_tdgrwrsdfSXUd8kdPUGq_xDWeXkzAe12v6O_rIpW5vR7Wddy6bvGyhLcWjnlsgs--Q-QUNSL4O4; expires=Mon, 17-May-2021 08:17:26 GMT; path=/; domain=.google.com; HttpOnly
< Accept-Ranges: none
< Vary: Accept-Encoding
< Connection: close
< Transfer-Encoding: chunked
< Proxy-Connection: keep-alive
若要关闭代理,只需要将对应的值设为空值即可:
set http_proxy=
set https_proxy=