shadowsocks
是一个socket5
的服务,对此,可以使用Privoxy
将其转化为http
部署shadowsocks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# 安装
pip install shadowsocks
# 创建配置文件
vim /etc/shadowsocks.json
# 输入
{
"server": "*.*.*.*",
"server_port": 443,
"password": "***",
"method": "aes-256-cfb",
"local_address": "0.0.0.0",
"local_port": 1080,
"workers": 1
}
# 运行
sslocal -c /etc/shadowsocks.json
# 测试当前ip
curl --socks5 127.0.0.1:1080 http://httpbin.org/ip
#返回结果
{
"origin": "*.*.*.*"
}
|
说明代理成功,接下来安装Privoxy
:
socket5转http
1
2
3
4
5
6
7
|
yum install -y privoxy
# 编辑配置文件
vim /etc/privoxy/config
# 添加
forward-socks5 / 127.0.0.1:1080 .
systemctl restart privoxy
systemctl status privoxy
|
若果需要在外网访问,则需在/etc/privoxy/config
添加listen-address 0.0.0.0:8118
,同时还需要将8118端口开启,假设使用iptables:
1
2
3
4
5
6
7
8
9
10
11
12
|
/etc/sysconfig/iptables
# 添加
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8118 -j ACCEPT
# 重启
systemctl restart iptables
systemctl status iptables
# 测试
vim ~/.bashrc
export http_proxy=http://127.0.0.1:8118
export https_proxy=http://127.0.0.1:8118
# 成功会有一大串返回
curl www.google.co
|
题外话
顺便一提,如果使用的是mac,需要使用代理服务,若已经配置好shadowsocks
:
1
2
3
4
5
6
7
|
brew install privoxy
vim /usr/local/etc/privoxy/config
# 添加
listen-address 0.0.0.0:8118
forward-socks5 / 127.0.0.1:1080 .
# 开启
/usr/local/sbin/privoxy /usr/local/etc/privoxy/config
|