ubuntu使用Shadowsocks及Privoxy配置代理访问外网

Shadowsocks安装(已安装略过)

下载get-pip文件

wget https://bootstrap.pypa.io/get-pip.py

安装shadowsocks

python get-pip.py
pip install shadowsocks

shadowsocks配置文件

sudo vim /etc/shadowsocks.json
{ 
"server":"your.server.ip",
"local_address": "127.0.0.1", 
"local_port":1081, 
"server_port":yourserver_port, 
"password":"yourpasswd", 
"timeout":300, 
"method":"aes-256-cfb"
}

启动shadowsock客户端

sslocal -c /etc/shadowsocks.json -d start

停止shadowsock客户端

sslocal -c /etc/shadowsocks.json -d stop

由于shadowsocks是socket5代理,在shell里发起的请求只能使用http/https代理,所以需要安装privoxy代理,来把http请求转发给shadowsocks.

Privoxy安装

sudo apt-get update
sudo apt-get install privoxy

privoxy配置

vim /etc/privoxy/config

注释掉: listen-address [::1]:8118

#listen-address  [::1]:8118

最后一行添加, 注意最后的端口需要跟shadowsocks中配置的相吻合:

forward-socks5 / 127.0.0.1:1081 .

启动

systemctl restart privoxy

环境变量

~/.bashrc或者~/.zshrc中配置:

alias proxy='export http_proxy=127.0.0.1:8118;export https_proxy=127.0.0.1:8118;export ftp_proxy=127.0.0.1:8118'
alias unproxy='unset http_proxy https_proxy ftp_proxy'

验证

启动ss

sslocal -c /etc/shadowsocks.json -d start

启动privoxy

systemctl restart privoxy

测试

// 开启
➜  ~ proxy
➜  ~ curl ip.gs
Current IP / 当前 IP: **.**.**.**
ISP / 运营商:  **.**
City / 城市: Los Angeles California
Country / 国家: United States
IP.GS is now IP.SB, please visit https://ip.sb/ for more information. / IP.GS 已更改为 IP.SB ,请访问 https://ip.sb/ 获取更详细 IP 信息!
Please join Telegram group https://t.me/sbfans if you have any issues. / 如有问题,请加入 Telegram 群 https://t.me/sbfans

  /\_/\
=( °w° )=
  )   (  //
 (__ __)//


// 关闭
➜  ~ unproxy
➜  ~ curl ip.gs
Current IP / 当前 IP: **.**.**.**
ISP / 运营商: tencent.com ChinaTelecom
City / 城市: Beijing Beijing
Country / 国家: China
IP.GS is now IP.SB, please visit https://ip.sb/ for more information. / IP.GS 已更改为 IP.SB ,请访问 https://ip.sb/ 获取更详细 IP 信息!
Please join Telegram group https://t.me/sbfans if you have any issues. / 如有问题,请加入 Telegram 群 https://t.me/sbfans

  /\_/\
=( °w° )=
  )   (  //
 (__ __)//
订阅评论
提醒
guest
0 评论
内联反馈
查看所有评论
0
希望看到您的想法,请您发表评论x