在编译Spigot服务端的时候频繁遇到访问github太慢导致卡住的情况,虽然可以通过路由插件来加速,但毕竟不是长久之计。所以本文整理了 Windows 命令行 和 Linux 终端以及 Git 中设置代理的命令。以本地 HTTP/HTTPS 代理 127.0.0.1:8118 和 SOCKS5 代理 127.0.0.1:1080 为例。
Windows 命令行代理设置
HTTP 代理设置:
set http_proxy=http://127.0.0.1:8118
set https_proxy=http://127.0.0.1:8118
SOCKS5 代理设置:
set http_proxy=socks5://127.0.0.1:1080
set https_proxy=socks5://127.0.0.1:1080
可以通过 echo %http_proxy%
命令查看是否设置成功。
取消代理设置:
set http_proxy=
set https_proxy=
Linux 终端代理设置
临时代理设置
Linux 终端设置 HTTP 代理(只对当前终端有效):
$ export http_proxy=http://127.0.0.1:8118
$ export https_proxy=http://127.0.0.1:8118
Linux 中设置 SOCKS5 代理(只对当前终端有效):
$ export http_proxy=socks5://127.0.0.1:1080
$ export https_proxy=socks5://127.0.0.1:1080
设置终端中的 wget、curl 等都走 SOCKS5 代理(只对当前终端有效):
$ export ALL_PROXY=socks5://127.0.0.1:1080
Linux 终端中取消代理设置:
$ unset http_proxy
$ unset https_proxy
$ unset ALL_RPOXY
永久代理设置
将代理命令写入配置文件 ~/.profile 或 ~/.bashrc 或 ~/.zshrc 中:
HTTP 代理设置
export http_proxy=http://127.0.0.1:8118
export https_proxy=http://127.0.0.1:8118
或
SOCKS5 代理设置
export http_proxy=socks5://127.0.0.1:1080
export https_proxy=socks5://127.0.0.1:1080
或
强制终端中的 wget、curl 等都走 SOCKS5 代理
export ALL_PROXY=socks5://127.0.0.1:1080
Git 设置代理
代理格式 [protocol://][user[:password]@]proxyhost[:port]
参考 https://git-scm.com/docs/git-config
设置 HTTP 代理:
git config --global http.proxy http://127.0.0.1:8118
git config --global https.proxy http://127.0.0.1:8118
设置 SOCKS5 代理:
git config --global http.proxy socks5://127.0.0.1:1080
git config --global https.proxy socks5://127.0.0.1:1080
Git 取消代理设置:
git config --global --unset http.proxy
git config --global --unset https.proxy
!!!
<div class="cpu-feeds-block" data-site-id="275522059" data-block-id="70093"></div>
<script>
(function(){var url="//cpu.baidu.com";var getEntry=function(){var script=document.createElement("script");script.id="cpu-block-entry";script.src=url+"/js/cb_pc.js";var scriptTag=document.getElementsByTagName("script")[0];scriptTag.parentNode.insertBefore(script,scriptTag)};var sentMsg=function(e){var msg={msg:e.toString()||"no err msg",line:e.lineno||-1};var img=document.createElement("img");if(JSON){msg=encodeURIComponent(JSON.stringify(msg))}else{msg="&line="+msg.line+"&msg="+msg.msg}img.src=url+"/msg?m=block&e="+msg};try{window.feedsbycpu=window.feedsbycpu||[];window.feedsbycpu.push({siteId:"275522059",blockId:"70093",display:"auto"});document.getElementById("cpu-block-entry")||getEntry()}catch(e){sentMsg(e)}})();
</script>
!!!
最后一次更新于September 23rd, 2020