Page

【linux】centos6安装shadowsocks客户端 + privoxy实现非全局代理

1785Anson19-09-11


由于需要经常在linux上下载github的代码,所以根据网上资料给linux配置了shadowsocks client实现访问特定网站使用代理模式

1、准备工具

  1. Centos6

  2. Python

  3. Shadowsocks服务端账号密码


2、安装Shadowsocks

yum install python-pip
pip install shadowsocks

vim /etc/shadowsocks-client.json

# 添加以下内容
{ 
    "server":"shadowsocks服务端ip",
    "server_port":shadowsocks服务端端口,
    "local_address": "127.0.0.1",
    "local_port":1080,
    "password":"shadowsocks服务端密码",
    "timeout":300,
    "method":"aes-256-cfb",  # 对应的加密方式
    "fast_open": false,
    "workers": 1
}


3、启动Shadowsocks客户端(可写脚本添加到开启自启动项目)

nohup sslocal -c /etc/shadowsocks-client.json  /dev/null 2>&1 &


4、检查全局模式是否启动成功

curl --socks5 127.0.0.1:1080 
# 若origin为服务器ip则表示成功,为本机ip则表示失败
{
  "origin": "shadowsocks服务器ip"
}


5、使用privoxy把流量转发到http、https服务上

shadowsocks是一个socket5服务,不能直接用在http上,所以需要使用privoxy代理转发到http流量上。

yum -y install privoxy

vi /etc/privoxy/config
listen-address 127.0.0.1:8118  # 确保有这一行即可

service privoxy start
chkconfig privoxy on  # 开机自启动


6、配置privoxy环境变量

vi /etc/profile

# 添加如下变量
export http_proxy=http://127.0.0.1:8118  #这里的端口和上面 privoxy 中的保持一致
export https_proxy=# 使配置生效
source /etc/profile


7、配置gfwlist翻墙域名列表

# 获取 gfwlist2privoxy 脚本
curl -4sSkLO 

# 执行脚本生成gfwlist.action文件
bash gfwlist2privoxy '127.0.0.1:1080'

# 移动文件到privoxy目录 
mv -f gfwlist.action /etc/privoxy

# 指定列表配置
echo 'actionsfile gfwlist.action' >>/etc/privoxy/config

# 重启代理
service privoxy restart



8、校验结果

curl -4sSkL   # 正常显示本机ip
curl -I       # 正常返回200

image.png

image.png


参考:

https://i4t.com/2778.html

https://www.zfl9.com/ss-local.html


来自ansion博客 

http://www.tp0.top

2019-09-11 16:14:06