Linux下使用socks5代理

1,安裝shadowsocks
安裝pip
yum install python-setuptools && easy_install pip
安裝shadowsocks
pip install shadowsocks

2.創建shadowsocks配置文件

vi /etc/shadowsocks.json

{
"server":"119.28.0.88",
"server_port":8388,
"local_port":1080,
"password":"password",
"timeout":600,
"method":"aes-256-cfb"
}
3.啓動ss-server

ssserver -c /etc/shadowsocks.json
4.啓動 ss-local

sslocal -c /etc/shadowsocks.json -d start
執行 ps aux | grep sslocal | grep -v “grep” 可查看後臺 sslocal 是否運行

5.安裝privoxy
上述安好了 shadowsocks,但它是 socks5 代理,我門在 shell 裏執行的命令,發起的網絡請求現在還不支持 socks5 代理,只支持 http/https 代理。爲了我門需要安裝 privoxy 代理,它能把電腦上所有 http 請求轉發給 shadowsocks。

wget http://www.privoxy.org/sf-download-mirror/Sources/3.0.26%20%28stable%29/privoxy-3.0.26-stable-src.tar.gz
tar -zxvf privoxy-3.0.26-stable-src.tar.gz
cd privoxy-3.0.26-stable
若上述地址無法連接可替換爲本站鏈接 http://blog.liuguofeng.com/wp-content/uploads/2018/07/privoxy-3.0.26-stable-src.tar.gz

新建一個 privoxy 用戶用來運行

useradd privoxy
編譯安裝

autoheader && autoconf
./configure
make && make install
配置

vim /usr/local/etc/privoxy/config
確保下面兩句沒有被註釋

listen-address 127.0.0.1:8118 # 8118 是默認端口,不用改,下面會用到
forward-socks5t / 127.0.0.1:1080 # 這裏的端口寫 shadowsocks 的本地端口
使用 privoxy-gfwlist

獲取 privoxy-gfwlist

wget https://raw.github.com/zfl9/gfwlist2privoxy/master/gfwlist2privoxy
bash gfwlist2privoxy '127.0.0.1:1080'
cp gfwlist.action /usr/local/etc/privoxy
echo 'actionsfile gfwlist.action' >> /usr/local/etc/privoxy/config
啓動 privoxy

privoxy --user privoxy /usr/local/etc/privoxy/config
配置 /etc/profile

vim /etc/profile
輸入內容

export http_proxy=http://127.0.0.1:8118 #這裏的端口和上面 privoxy 中的保持一致
export https_proxy=http://127.0.0.1:8118
export ftp_proxy=http://127.0.0.1:8118 #ftp可以不用
export no_proxy="localhost, 127.0.0.1, ::1, aliyuncs.com, qiniuapi.com, qiniu.com, qiniucdn.com"
刷新

source /etc/profile

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章