启动服务器
- 使用sudo命令启动服务器:
sudo systemctl restart server
这将启动所有服务器,包括SS代理。
注册SS代理服务
-
创建服务文件: 创建一个名为
ss代理.service.xml的文件,包含代理服务的配置,文件内容应如下:<service id="server代理"> <name>ss代理</name> <type>http</type> <description>服务器代理</description> <uri>http://localhost:88/</uri> <sa>server</sa> <sas>1</sas> <start_time>now</start_time> <stop_time>now</stop_time> <connects> <event>offconnect</event> <event>connect</event> </connects> <components> <component>server代理</component> </components> </service> -
运行服务配置: 在服务管理界面(通常通过sudo systemctl 或命令行命令)中运行配置:
sudo systemctl create service ss代理
然后启用此服务:
sudo systemctl enable service ss代理
设置代理名称和端口
-
选择代理名称:
- 在服务管理界面中选择“代理”服务,右键点击,选择“属性”。
- 在“名称”字段中输入代理名称,ss”或“server”.ss”。
-
设置端口:
- 在“端口”字段中设置服务端的IP地址和端口,
- HTTP:88
- HTTPS:884
- 或反之,根据服务器连接方式设置。
- 在“端口”字段中设置服务端的IP地址和端口,
运行服务配置
-
启动服务: 在服务管理界面中运行代理服务配置:
sudo systemctl start service ss代理
设置连接规则
-
关闭连接机制:
-
自动关闭服务端的端口:
- 在“连接规则”中添加事件
connect,在处理时关闭服务端的端口:<connects> <event>connect</event> <event>offconnect</event> <event>stopPort</event> </connects> - 然后启用此事件:
sudo systemctl enable service ss代理connects
- 在“连接规则”中添加事件
-
自动关闭连接:
- 在“连接规则”中添加事件
stopOnExit,在处理时关闭服务:<connects> <event>stopPort</event> <event>stopOnExit</event> </connects> - 然后启用此事件:
sudo systemctl enable service ss代理stopOnExit
- 在“连接规则”中添加事件
-
-
连接到目标服务器:
- 在“连接规则”中添加事件
connect,在处理时启动目标服务器:<connects> <event>connect</event> <event>stopPort</event> <event>startPort</event> </connects>
然后启用此事件:
sudo systemctl enable service ss代理connects
- 在“连接规则”中添加事件
配置代理的逻辑
-
启用路由:
- 在“路由”规则中启用路由策略,例如
route规则:<connects> <event>connect</event> <event>route</event> <event>stopPort</event> </connects>
然后启用此规则:
sudo systemctl enable service ss代理route
- 在“路由”规则中启用路由策略,例如
-
配置缓存策略:
- 在“缓存”规则中启用缓存策略,例如
cache规则:<connects> <event>connect</event> <event>cache</event> <event>stopPort</event> </connects>
然后启用此规则:
sudo systemctl enable service ss代理cache
- 在“缓存”规则中启用缓存策略,例如
运行配置
-
启动代理服务: 在服务管理界面中运行代理服务配置:
sudo systemctl start service ss代理
然后启用代理服务:
sudo systemctl enable service ss代理
测试配置
-
访问目标服务器:
- 使用终端访问目标服务器地址,通过代理服务访问,确保代理配置正确:
sudo systemctl list service ss代理
-
查看代理状态:
- 在终端中查看代理的状态,确保代理正常运行:
sudo systemctl status service ss代理
更新配置
-
定期更新配置:
- 使用
systemctl命令更新代理服务配置:
sudo systemctl update service ss代理
- 使用
注意事项
- 自动关闭:确保代理在服务退出时自动关闭连接,避免不必要的资源占用。
- 配置顺序:按照以下顺序配置,确保所有规则正确生效:
- 启动服务器
- 创建代理服务
- 设置代理名称和端口
- 设置连接规则
- 设置代理逻辑
通过以上步骤,您可以正确设置并运行SS代理,确保服务器之间的高效通信。
