目录
转自:
hongyuanyu.github.io/2019/04/24/centos%E9%85%8D%E7%BD%AEshadowsocks%E5%AE%A2%E6%88%B7%E7%AB%AF/CentOS 7安装配置Shadowsocks客户端
1. 安装配置Shadowsocks客户端
1.1 安装Shadowsocks客户端
安装epel扩展源采用Python包管理工pip安装。sudo yum -y install epel-releasesudo yum -y install python-pip安装Shadowsocks客户端sudo pip install shadowsocks1.2 配置Shadowsocks客户端
新建配置文件sudo mkdir /etc/shadowsockssudo vi /etc/shadowsocks/shadowsocks.json添加配置信息{"server":"1.1.1.1","server_port":1035,"local_address": "127.0.0.1","local_port":1080,"password":"password","timeout":300,"method":"aes-256-cfb","fast_open": false,"workers": 1}参数说明:server:Shadowsocks服务器地址server_port:Shadowsocks服务器端口local_address:本地IPlocal_port:本地端口password:Shadowsocks连接密码timeout:等待超时时间method:加密方式workers:工作线程数fast_open:true或false。开启fast_open以降低延迟,但要求Linux内核在3.7+。开启方法 echo 3 > /proc/sys/net/ipv4/tcp_fastopen
配置自启动① 新建启动脚本文件/etc/systemd/system/shadowsocks.service,内容如下:[Unit]Description=Shadowsocks[Service]TimeoutStartSec=0ExecStart=/usr/bin/sslocal -c /etc/shadowsocks/shadowsocks.json[Install]WantedBy=multi-user.target② 启动Shadowsocks客户端
systemctl enable shadowsocks.servicesystemctl start shadowsocks.servicesystemctl status shadowsocks.service验证Shadowsocks客户端是否正常运行curl --socks5 127.0.0.1:1080若Shadowsock客户端已正常运行,则结果如下:
{"origin": "x.x.x.x" #你的Shadowsock服务器IP}2. 安装配置Privoxy
Shadowsocks是一个 socket5 服务,我们需要使用 Privoxy 把流量转到 http/https 上。
2.1 安装Privoxy
安装Privoxysudo yum -y install privoxy启动Privoxysystemctl enable privoxysystemctl start privoxysystemctl status privoxy2.2 配置Privoxy
配置Privoxy① 修改配置文件/etc/privoxy/configsudo vi /etc/privoxy/config② 确保如下内容没有被注释掉
listen-address 127.0.0.1:8118 # 8118 是默认端口,不用改forward-socks5t / 127.0.0.1:1080 . #转发到本地端口设置http/https代理① 修改配置文件/etc/profilesudo vi /etc/profile添加如下信息:
export http_proxy=:8118export https_proxy=:8118source /etc/profile注:端口和privoxy 中的监听端口保持一致
验证是否可用curl www.google.com