利用VPS爲終端設置SS代理服務

爲什麼要設置終端代理服務

在看influxdb源碼的時候,需要使用dep ensure來安裝influxdb的依賴包。但是出現了一些依賴包下不過來的問題,才發現需要終端掛代理纔可以。

如何設置終端SS代理服務

首先需要了解終端SS代理服務的原理,SS是我們常用的代理工具,但是這個工具使用是socks5協議。但是終端一般都是隻支持HTTP等協議。所以我們需要一箇中間工具把socks5協議轉爲終端可以支持的HTTP協議。

準備工作

首先需要配置一個SS,如果不知道如何配置或者沒有購買的話就使用搬瓦工。具體使用這裏就不多講了,可以自己查找。

終端配置

安裝polipo 工具

polipo工具就爲我們將socks5協議轉化爲http協議的工具

mac

brew install polipo

polipo登錄啓動

  1. 執行 ln -sfv /usr/local/opt/polipo/*.plist ~/Library/LaunchAgents
  2. 執行 vim /usr/local/opt/polipo/homebrew.mxcl.polipo.plist
    在其中添加<string>socksParentProxy=localhost:1080</string>,結果如下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
<plist version="1.0">
<dict>
<key>Label</key>
<string>homebrew.mxcl.polipo</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/polipo/bin/polipo</string>
<!--添加這一行-->
<string>socksParentProxy=localhost:1080</string>
</array>
<!-- Set ulimit -n 65536. The default macOS limit is 256, that's
not enough for Polipo (displays 'too many files open' errors).
It seems like you have no reason to lower this limit
(and unlikely will want to raise it). -->
<key>SoftResourceLimits</key>
<dict>
<key>NumberOfFiles</key>
<integer>65536</integer>
</dict>
</dict>
</plist>

啓動和關閉polipo

// 關閉
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.polipo.plist
// 啓動
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.polipo.plist

至此全部的工作已經結束,你只需要啓動polipo即可。然後在終端發送http_proxy=http://localhost:8123 curl ip.gs進行測試。
利用VPS爲終端設置SS代理服務
但是每條命令都需要設置代理是非常麻煩的,那麼就參考其他工作的內容。

其他工作

  1. 設置別名(使用更加方便,強烈推薦配置)
  2. linux下配置
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章