注:本文全篇分爲兩個板塊,第一部分爲如何搭建shadowsocks服務端搭建,第二部爲linux下shadowsocks客戶端的搭建及連接。第三部分爲,各平臺shadowsocks下載地址
第一部分
此部分來源於https://github.com/uxh/shadowsocks_bash
#作者:https://www.banwagongzw.com & https://www.vultrcn.com
#致謝:https://teddysun.com
此部分較爲簡單,爲以上作者所提供的一件安裝,分別爲
Shadowsocks-Python
ShadowsocksR
Shadowsocks-Go
Shadowsocks-libev
就歷史種種原因,我建議安裝ShadowsocksR版本,雖然大致都是相同的。
首先,先安裝wget
yum install -y wget
安裝完成以後粘貼如下
wget --no-check-certificate -O shadowsocks-all.sh https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-all.sh
chmod +x shadowsocks-all.sh
./shadowsocks-all.sh 2>&1 | tee shadowsocks-all.log
執行完最後一步顯示
隨意選擇就好,建議選2
接着彈出,輸入密碼
接着選擇端口
然後身下就是配置協議等等,直接回車默認跳轉下一步即可
安裝過程大約15分鐘。。。,隨後顯示如下
最好把這一段全部複製,保存一下
以下各版本啓動腳本
啓動腳本後面的參數含義,從左至右依次爲:啓動,停止,重啓,查看狀態。
Shadowsocks-Python 版:
/etc/init.d/shadowsocks-python start | stop | restart | status
ShadowsocksR 版:
/etc/init.d/shadowsocks-r start | stop | restart | status
Shadowsocks-Go 版:
/etc/init.d/shadowsocks-go start | stop | restart | status
Shadowsocks-libev 版:
/etc/init.d/shadowsocks-libev start | stop | restart | status
各版本配置文件(建議單獨保存一下)
Shadowsocks-Python 版:
/etc/shadowsocks-python/config.json
ShadowsocksR 版:
/etc/shadowsocks-r/config.json
Shadowsocks-Go 版:
/etc/shadowsocks-go/config.json
Shadowsocks-libev 版:
/etc/shadowsocks-libev/config.json
卸載命令
./shadowsocks-all.sh uninstall
第二部分
客戶端在各個平臺上不一樣,此處主要介紹centos7下的shadowsocks安裝方法,文章結尾處另附各個平臺推薦軟件
1、配置epel源,安裝python-pip,輸入命令
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum install python-pip
安裝完成以後運行升級
pip install --upgrade pip
2、安裝shadowsocks
pip install shadowsocks
提示這個就已經安裝成功
3、創建配置文件目錄
mkdir /etc/shadowsocks
將上方服務器端配置版本文件對應的config.json複製到/etc/shadowsocks/shadowsocks.json目錄內
輸入編輯
vi /etc/shadowsocks/shadowsocks.json
備註:
server填寫服務器的公網IP
server_port代理服務器設置的端口
password代理服務器密碼
localport爲本地shadowsocks啓動端口
這幾個參數很好理解,前提是你瞭解過並且有ss代理
4、配置自啓動
輸入命令
vi /etc/systemd/system/shadowsocks.service
添加以下內容
[Unit]
Description=Shadowsocks
[Service]
TimeoutStartSec=0
ExecStart=/usr/bin/sslocal -c /etc/shadowsocks/shadowsocks.json
[Install]
WantedBy=multi-user.target
5、啓動shadowsocks客戶端
enable和disable爲開關自啓
start和stop爲開關
status是查看狀態
命令如下
systemctl enable shadowsocks.service
systemctl start shadowsocks.service
systemctl status shadowsocks
6、驗證
驗證shadowsocks客戶端是否正常運行,127.0.0.1:1080爲shadowsocks本地監聽端口域名,正常會返回你的代理IP
curl --socks5 127.0.0.1:1080 http://httpbin.org/ip
7、安裝配置privoxy
Shadowsocks是一個socket5服務,我們需要使用privoxy把流量轉到http/https上
yum install privoxy
8、啓動privoxy
命令規則同上
systemctl enable privoxy
systemctl start privoxy
systemctl status privoxy
9、配置privoxy
vi /etc/privoxy/config
找到一下兩行,forward-socks5t這裏端口改成1080表示來源於shadowsocks,listen-address默認端口不用改,表示轉發出來的端口
listen-address 127.0.0.1:8118
forward-socks5t / 127.0.0.1:1080
10、修改/etc/profile
vi /etc/profile
在最下面添加以下內容,表示http和https的網絡請求,通過privoxy轉發出來的127.0.0.1:8118端口代理。
export http_proxy=http://127.0.0.1:8118
export https_proxy=http://127.0.0.1:8118
再輸入,使配置文件生效
source /etc/profile
11、驗證
最後就可以驗證了
curl http://httpbin.org/ip 返回值如果爲服務器段ip則成功
如果可以正常返回內容,即表示配置成功
如需恢復,通過上方相關命令關閉shadowsocks和privoxy再把/etc/profile文件中的代理關掉即可
附錄
蘋果ios軟件shadowrock下載地址https://www.neicexia.com/v/F795W
安卓apk ShadowsocksR下載位置https://help.fengye.la/res/ShadowsocksR-android.apk
Windows ShadowsocksR下載地址https://help.fengye.la/res/ShadowsocksR-win.zip
如需直接購買shadowsock節點,可以聯繫我,我給你推薦。當然,我不是賣這個的。