0%

CentOS7 安装 Shadowsocks 客户端

CentOS7 安装 Shadowsocks 客户端

服务器无法访问 GG 资源,在 CentOS7 环境安装配置 Shadowsocks 客户端、Privoxy 程序,用于方便快捷的编译 Go 程序、安装 K8S 等。

CentOS 版本:7.5 x86_64

Shadowsocks 版本:2.8.2

Privoxy 版本:3.0.26

安装配置 Shadowsocks

安装 YUM 源

1
2
yum install -y epel-release curl
yum makecache fast

安装 pip

1
yum install -y python-pip

创建 pip 源

1
2
3
4
5
6
mkdir /root/.pip
cat > /root/.pip/pip.conf << EOF
[global]
trusted-host = pypi.douban.com
index-url = http://pypi.douban.com/simple
EOF

升级 pip

1
pip install --upgrade pip

安装 shadowsocks

1
pip install shadowsocks

创建 shadowsocks 配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
mkdir /etc/shadowsocks
cat > /etc/shadowsocks/shadowsocks.json << EOF
{
"server":"SS 服务端 IP",
"server_port":"SS 服务端端口",
"local_address": "127.0.0.1",
"local_port":1080,
"password":"SS 服务端密码",
"timeout":300,
"method":"aes-256-cfb",
"fast_open": false,
"workers": 1
}
EOF

创建 shadowsocks 服务

1
2
3
4
5
6
7
8
9
cat > /etc/systemd/system/shadowsocks.service << EOF
[Unit]
Description=Shadowsocks
[Service]
TimeoutStartSec=0
ExecStart=/usr/bin/sslocal -c /etc/shadowsocks/shadowsocks.json
[Install]
WantedBy=multi-user.target
EOF

启动 shadowsocks 服务

1
2
3
systemctl enable shadowsocks.service
systemctl start shadowsocks.service
systemctl status shadowsocks

检查 shadowsocks 客户端配置,正常会返回 shadowsocks 服务端 IP

1
curl --socks5 127.0.0.1:1080 http://httpbin.org/ip

安装配置 privoxy

YUM 安装 privoxy

1
yum install privoxy

修改 privoxy 配置文件 /etc/privoxy/config

1
2
listen-address 127.0.0.1:8118
forward-socks5t / 127.0.0.1:1080 .

启动 privoxy 服务

1
2
3
systemctl enable privoxy
systemctl start privoxy
systemctl status privoxy

设置代理环境变量

1
2
3
echo -e "export http_proxy=http://127.0.0.1:8118" >> /etc/profile
echo -e "export https_proxy=http://127.0.0.1:8118" >> /etc/profile
source /etc/profile

测试访问 GG

1
curl www.google.com