51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

linux安装部署shadowsocks

Shadowsocks 简介

Shadowsocks(中文名称:影梭)是一个跨平台软件、基于Apache许可证的开放源代码软件,用于保护网络流量、加密数据传输。Shadowsocks使用Socks5代理方式,Shadowsocks分为服务器端和客户端,Shadowsocks是一个轻量级SOCKS5代理。

一、安装shadowsocks文章源自小柒网-https://www.yangxingzhen.cn/7352.html

1、安装第三方扩展源文章源自小柒网-https://www.yangxingzhen.cn/7352.html

[root@localhost ~]# yum -y install epel-release文章源自小柒网-https://www.yangxingzhen.cn/7352.html

安装pip文章源自小柒网-https://www.yangxingzhen.cn/7352.html

[root@localhost ~]# yum -y install python-pip python-setuptools m2crypto文章源自小柒网-https://www.yangxingzhen.cn/7352.html

安装shadowsocks文章源自小柒网-https://www.yangxingzhen.cn/7352.html

[root@localhost ~]# pip install shadowsocks文章源自小柒网-https://www.yangxingzhen.cn/7352.html

Collecting shadowsocks文章源自小柒网-https://www.yangxingzhen.cn/7352.html

Downloading https://files.pythonhosted.org/packages/02/1e/e3a5135255d06813aca6631da31768d44f63692480af3a1621818008eb4a/shadows文章源自小柒网-https://www.yangxingzhen.cn/7352.html

ocks-2.8.2.tar.gzInstalling collected packages: shadowsocks文章源自小柒网-https://www.yangxingzhen.cn/7352.html

Running setup.py install for shadowsocks ... done

Successfully installed shadowsocks-2.8.2

You are using pip version 8.1.2, however version 20.2 is available.

You should consider upgrading via the 'pip install --upgrade pip' command.

升级pip

[root@localhost ~]# pip install --upgrade pip

Collecting pip

Downloading https://files.pythonhosted.org/packages/36/74/38c2410d688ac7b48afa07d413674afc1f903c1c1f854de51dc8eb2367a5/pip-20.2-py2.py3-none-any.whl (1.5MB) 100% |████████████████████████████████| 1.5MB 26kB/s

Installing collected packages: pip

Found existing installation: pip 8.1.2

Uninstalling pip-8.1.2:

Successfully uninstalled pip-8.1.2

Successfully installed pip-20.2

再次执行pip安装

[root@localhost ~]# pip install shadowsocks

Requirement already satisfied: shadowsocks in /usr/lib/python2.7/site-packages (2.8.2)

2、创建配置文件,json文件方式

[root@localhost ~]# mkdir -p /etc/shadowsocks

[root@localhost ~]# vim /etc/shadowsocks/shadowsocks.json

内容如下

{
	"server": "本机IP",
	"server_port": 13090,
	"local_port": 1080,
	"password": "123456",
	"timeout": 600,
	"method": "aes-256-cfb",
	"fast_open": false,
	"workers": 1,
	"prefer_ipv6": false
}

提示:若需同时指定多个服务端地址,使用如下语法"server":["1.1.1.1", "2.2.2.2"].

|---------------|---------------------| | 名称 | 解释 | | server | 服务端监听地址 | | server_port | 服务端端口 | | local_address | 本地监听地址 | | local_port | 本地端口 | | password | 用于加密的密码 | | timeout | 超时时间(秒) | | method | 加密方式,默认为aes-256-cfb | | mode | 是否启用 TCP / UDP 转发 | | fast_open | 是否启用 TCP Fast Open | | workers | worker 数量 |

3、后台运行

[root@localhost ~]# nohup sslocal -c /etc/shadowsocks/shadowsocks.json >/dev/null 2>&1 &

4、查询端口

[root@localhost ~]# netstat -lntup

二、转换http代理

Shadowsocks默认是用Socks5协议的,对于Terminal的get,wget等走Http协议的地方是无能为力的,所以需要转换成Http代理,加强通用性,这里使用的转换方法是基于Polipo的。

1、安装依赖

[root@localhost ~]# yum -y install texinfo gcc gcc-c++ make wget

2、下载polopo安装包

[root@localhost ~]# wget https://www.irif.fr/~jch/software/files/polipo/polipo-1.1.1.tar.gz

解压

[root@localhost ~]# tar xf polipo-1.1.1.tar.gz

[root@localhost ~]# cd polipo-1.1.1

编译及安装

[root@localhost polipo-1.1.1]# make && make install

3、创建配置文件目录

[root@localhost polipo-1.1.1]# mkdir /etc/polipo

[root@localhost polipo-1.1.1]# cp config.sample /etc/polipo/config

4、编辑配置文件

[root@localhost polipo-1.1.1]# vim /etc/polipo/config

配置内容如下

logSyslog = true
logFile = /var/log/polipo/polipo.log
socksParentProxy = "127.0.0.1:1080"
socksProxyType = socks5
chunkHighMark = 50331648
objectHighMark = 16384
serverMaxSlots = 64
serverSlots = 16
serverSlots1 = 32
proxyAddress = "0.0.0.0"
proxyPort = 8123

5、创建日志目录

[root@localhost polipo-1.1.1]# mkdir /var/log/polipo

6、后台启动

[root@localhost polipo-1.1.1]# nohup polipo >/dev/null 2>&1 &

7、查询端口

[root@localhost polipo-1.1.1]# netstat -lntup

8、测试验证是否成功

[root@localhost ~]# export http_proxy="http://127.0.0.1:8123/"

[root@localhost ~]# curl www.google.com

如果正常返回google网页,即为成功。

9、添加开机自启动

[root@localhost ~]# echo "nohup sslocal -c /etc/shadowsocks/shadowsocks.json >/dev/null 2>&1 &" >> /etc/rc.local

[root@localhost ~]# echo "nohup polipo >/dev/null 2>&1 &" >> /etc/rc.local

授权

[root@localhost ~]# chmod +x /etc/rc.d/rc.local

至此,Shadowsocks搭建完成。
继续阅读 Linux最后更新:2022-11-25

赞(0)
未经允许不得转载:工具盒子 » linux安装部署shadowsocks