步骤1:安装必要的软件包
确保你的系统有最新的软件包管理工具:
sudo apt update && sudo apt upgrade -y
然后安装ShadowsocksR(推荐)或Shadowsocks:
sudo apt install shadowsocks shadowsocks-r
步骤2:安装完成后生成配置文件
使用ss-r(ShadowsocksR)或ss(Shadowsocks)生成配置文件:
sudo ss-r server --help
根据需要配置参数,
- 服务器地址:
--sserver 127...1:108 - 端口:
--port 108 - 加密方式:
--c chacha20 - 认证方式:
--auth "username:password"
生成配置文件:
sudo ss-r server --sserver 127...1:108 --port 108 --c chacha20 --auth "username:password" --save
文件保存在/etc/shadowsocks-r/config.json或~/.shadowsocks-r/config.json,根据你的选择。
步骤3:设置自动启动
使用systemd管理服务:
创建服务文件:
sudo nano /etc/systemd/system/shadowsocks.service
[Unit] Description=ShadowsocksR Proxy Server After=network.target [Service] ExecStart=/usr/bin/shadowsocks-r --config-file /etc/shadowsocks-r/config.json Restart=always User=shadowsocks Group=shadowsocks [Install] WantedBy=multi-user.target
启用并启动服务:
sudo systemctl daemon-reload sudo systemctl enable shadowsocks sudo systemctl start shadowsocks
步骤4:测试配置
启动服务后,使用curl或wget测试:
curl -v http://127...1:108
如果连接成功,会显示200 OK或类似结果。
步骤5:设置防火墙
确保防火墙允许代理端口:
sudo iptables -A INPUT -p tcp --dport 108 -j ACCEPT sudo service iptables save sudo service iptables restart
步骤6:管理用户
创建代理账户并设置权限:
sudo useradd -g shadowsocks -d /dev/null shadowsocks sudo passwd shadowsocks
步骤7:日志管理
检查日志:
journalctl -u shadowsocks -b
定期查看日志,确保服务正常运行。
完成
通过以上步骤,你已成功设置了一个ShadowsocksR代理服务器,确保网络环境支持代理端口,并根据需要调整配置。









