Shadowsocks libev 多端口配置方式
创建不同端口的配置文件
新建/etc/shadowsocks-libev/config_x.json
文件
{
"server":"server_ip",
"server_port": server_port,
"local_port": 1080,
"password": "custom password",
"timeout": 300,
"method": "aes-256-cfb",
"fast_open": true
}
创建ss批量启动脚本
新建 /usr/local/bin/shadowsocks-libev-autostart.sh
文件
#!/bin/bash
proc=/usr/local/bin/ss-server
config_dir=/etc/shadowsocks-libev
log_dir=/etc/shadowsocks-libev
arg=" -v "
config_files=()
files=$(ls ${config_dir}/config_*.json)
for f in ${files[@]}
do
fn=${f##*/}
nohup $proc -c $f $arg >> ${log_dir}/${fn%.*}.log 2>&1 &
done
添加执行权限
chmod 755 /usr/local/bin/shadowsocks-libev-autostart.sh
配置systemd自启动
创建文件/etc/systemd/system/sslibev.service
[Unit]
Description=Shadowsocks-ssserver
After=network.target
[Service]
Type=forking
TimeoutStartSec=3
ExecStart=/usr/local/bin/shadowsocks-libev-autostart.sh
Restart=always
[Install]
WantedBy=multi-user.target
注册systemd启动项,并运行
$ sudo systemctl enable /etc/systemd/system/sslibev.service #注册自启动
$ sudo systemctl start sslibev # 运行
使用方式
需要添加新端口的时候,新建/etc/shadowsocks-libev/config_{x}.json
文件,如config_1.json
、config_2.json
,配置对应端口和密码,然后重启systemd的sslibev
服务即可。
其他
$ sudo systemctl restart sslibev # 重启sslibev服务
$ sudo systemctl disable sslibev # 停用sslibev自启动
$ sudo rm /etc/systemd/system/sslibev.service # 移除sslibev启动项
$ systemctl status sslibev # 查看运行状态
$ ss -lnt # 查看tcp端口接听状态