WANG LH , Research & Development

科学上网

2021.12.21 11:48

购买VPS服务器

这里选择了阿里的轻量应用服务器,主要是便宜,最低配置即可。选择香港或者新加坡都可以,貌似只有这两个可选。

域名

搭建shadowsocks不需要域名,Trojan服务搭建会用到域名,Trojan速度更好,也不容易被封。

shadowsocks服务端搭建

首先服务器要有python commond,如果没有可能是没建立软链
ln -s /usr/bin/python3 /usr/bin/python

执行以下命令
wget https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks.sh

chmod +x shadowsocks.sh

chmod +x shadowsocks.sh

过程中会需要输入密码和端口号,最终配置文件在这里/etc/shadowsocks.json,后续如果端口被封可以在配置里换个端口重新启动即可。

启动:systemctl start shadowsocks.service
停止:systemctl stop shadowsocks.service
重启:systemctl restart shadowsocks.service
状态:systemctl status shadowsocks.service

遇到的问题

查看服务状态是inactive
尝试配置一下防火墙或者重启试试
配置防火墙
安装 ufw:
sudo apt update && sudo apt install -y ufw
允许 SSH 端口:
sudo ufw allow ssh
允许 shadowsocks-libev 端口,将端口替换为配置文件中指定的端口:
sudo ufw allow 12345/tcp
启动 ufw,按 Y 确认:
sudo ufw enable
检查 ufw 的状态:
sudo ufw status

客户端下载

macOS:https://github.com/shadowsocks/ShadowsocksX-NG/releases
windows:https://github.com/shadowsocks/shadowsocks-windows/releases

参考文章:https://www.zhanggaoyuan.com/article/4f7e349a.html
https://blog.lingyf.com/build-shadowsocks-server-to-cross-gfw/

Trojan服务端搭建

参考文章:https://www.itblogcn.com/article/1257.html
https://www.v2rayssr.com/trojanpanel.html/comment-page-2
https://www.v2rayssr.com/

参考这篇文章申请免费域名:https://zhuanlan.zhihu.com/p/115535965
我已经有了阿里的域名,所以直接在那个域名下开了个子域名直接就用了。

一键搭建

如果已经有wget,不用安装
yum install -y wget

执行命令:
wget -N --no-check-certificate -q -O trojan_install.sh "https://raw.githubusercontent.com/V2RaySSR/Trojan/master/trojan_install.sh" && chmod +x trojan_install.sh && bash trojan_install.sh

后续按照命令指示执行即可,中间会有一步SSL证书的问题,按照提示注册即可。

安装完成后会有官方客户端下载链接。

配置文件目录:/usr/src/trojan/server.conf

常用命令

启动
systemctl start trojan
重启
systemctl restart trojan
停止
systemctl stop trojan
状态查询(如果有显示绿色active(running),就表示正常运行中)
systemctl status trojan
错误查询
journalctl -e -u trojan.service
开机自动启动
systemctl enable trojan
禁止开机自动启动
systemctl disable trojan

客户端

客户端不是特别丰富,目前还没找到特比好用的。
电脑上,不管是window还是macOs,都是先下载官方客户端服务,让Ta在控制台后台运行,然后再在谷歌浏览器安装SwitchyOmega插件配合使用