如何在VPS上搭建SSR服务器?
| 步骤 |
操作说明 |
使用工具提示 |
模拟界面 |
| 1. 购买VPS |
选择国外VPS提供商(如Vultr、阿里云) |
推荐使用Ubuntu/CentOS系统 |
bash sudo apt update sudo apt upgrade |
| 2. 连接VPS |
使用SSH客户端(如PuTTY)连接 |
确保网络通畅 |
bash ssh username@yourvpsip |
| 3. 安装依赖 |
安装git、python等必要工具 |
根据系统选择命令 |
bash sudo apt install git python |
| 4. 下载SSR |
克隆ShadowsocksR仓库 |
使用官方仓库 |
bash git clone https://github.com/shadowsocksrr/shadowsocksr.git |
| 5. 配置SSR |
编辑config.json文件 |
设置端口、密码等参数 |
json { "server": "0.0.0.0", "serverport": 443, "password": "yourpassword" } |
| 6. 启动SSR |
运行服务端脚本 |
使用screen保持后台运行 |
bash python server.py -d start |
VPS搭建SSR服务器详细指南
一、准备工作
- 选择VPS提供商:推荐使用国际知名服务商(如Vultr、阿里云),选择境外服务器以避免国内网络限制^^1^^。
- 操作系统:建议Ubuntu 22.04或CentOS 7+,系统需更新至最新版本:
sudo apt update && sudo apt upgrade # Ubuntu
sudo yum update -y # CentOS
二、安装SSR步骤
- 安装依赖工具:
sudo apt install git python3 python3-pip # Ubuntu
sudo yum install git python3 python3-pip # CentOS
- 下载ShadowsocksR:
git clone https://github.com/shadowsocksrr/shadowsocksr.git
cd shadowsocksr
- 配置参数(编辑
user-config.json):
{
"server": "0.0.0.0",
"serverport": 8388,
"password": "yourstrongpassword",
"method": "aes-256-cfb"
}
- 启动服务:
python server.py -d start
三、防火墙配置
放行SSR端口(以UFirewall为例):
sudo ufw allow 8388/tcp
sudo ufw enable
四、常见问题解决方案
| 问题现象 |
可能原因 |
解决方法 |
| 连接超时 |
防火墙未放行端口 |
检查iptables -L或ufw status |
| 速度缓慢 |
服务器带宽不足 |
更换数据中心或升级配置 |
| 客户端报错 |
协议/混淆不匹配 |
确认method和obfs参数一致 |
五、性能优化建议
- 启用BBR拥塞控制算法:
echo "net.core.defaultqdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcpcongestioncontrol=bbr" >> /etc/sysctl.conf
sysctl -p
- 定期更新SSR版本以获取安全补丁:
cd shadowsocksr
git pull origin master
如需进一步验证配置是否生效,可使用
curl -x socks5://localhost:1080 https://www.google.com测试代理连通性。
发表评论