场景
客户端 --> VPS Shadowsocks --> VPS Clash (Socks5) --> VPS Clash --> Internet
安装 Clash
使用root身份:
sudo -i
在VPS上安装Clash客户端的最新版本,作为VPS内部的Socks5服务器。可以参考Clash官方文档的安装步骤进行安装。此处以v0.18.0版本为例:
wget https://github.com/Dreamacro/clash/releases/download/v0.18.0/clash-linux-amd64-v0.18.0.gz
gunzip clash-linux-amd64-v0.18.0.gz
mv clash-linux-amd64-v0.18.0 /usr/bin/clash
chmod +x /usr/bin/clash
检查Clash是否安装成功:
clash -v
注意:为了安全考虑,请不要开放Clash的http和socks代理端口在公网上。
新建 /etc/systemd/system/clash.service
:
nano /etc/systemd/system/clash.service
写入以下内容,保存:
[Unit]
Description=clash service
After=network.target
[Service]
Type=simple
User=root
ExecStart=/usr/bin/clash
Restart=on-failure # or always, on-abort, etc
[Install]
WantedBy=multi-user.target
让Clash随系统启动:
systemctl daemon-reload
systemctl enable clash
开放Clash配置端口9090,注意务必记得在Clash配置文件中设置好RESTful API的口令,不要留空。
// Ubuntu
ufw allow 9090
// Centos
firewall-cmd --zone=public --add-port=9090/tcp --permanent
firewall-cmd --reload
配置Clash
然后我们给config.yaml加上内容:
cd /$HOME/.config/clash
nano config.yaml
请参考Clash配置文件示例根据自己的需求自行配置规则和节点。
配置文件写好后,启动Clash:
systemctl start clash
systemctl status clash
可以通过官方Web UI来通过RESTful API管理Clash。
安装 V2Ray
curl -Ls https://install.direct/go.sh | sudo bash
配置 V2Ray
nano /etc/v2ray/config.json
参考以下配置,outbounds指向Clash的默认socks5代理7891端口:
{
"inbounds": [ {
"port": 此处设置SS服务器对外开放的连接端口,
"protocol": "shadowsocks",
"settings": {
"method": "此处设置加密方式比如aes-256-cfb",
"ota": false,
"password": "此处设置你的密码"
}
}],
"outbounds": [{
"protocol": "socks",
"settings": {
"servers": [{
"address": "127.0.0.1",
"port": 7891,
"auth": "noauth"
}]
}
}]
}
重启,让配置生效:
service v2ray restart
多用户管理面板
可以使用 v2-ui,一个全新的多协议多用户 v2ray 面板,进行多用户管理。
如果之前安装过 V2Ray,建议先卸载V2Ray。
#停用并卸载服务(systemd):
systemctl stop v2ray
systemctl disable v2ray
#停用并卸载服务(sysv):
service v2ray stop
update-rc.d -f v2ray remove
删除文件
rm -rf /etc/v2ray/* #(配置文件)
rm -rf /usr/bin/v2ray/* #(程序)
rm -rf /var/log/v2ray/* #(日志)
rm -rf /lib/systemd/system/v2ray.service #(systemd 启动项)
rm -rf /etc/init.d/v2ray #(sysv 启动项)
一键安装:
bash <(curl -Ls https://blog.sprov.xyz/v2-ui.sh)
v2-ui 管理脚本使用方法:
v2-ui - 显示管理菜单 (功能更多)
v2-ui start - 启动 v2-ui 面板
v2-ui stop - 停止 v2-ui 面板
v2-ui restart - 重启 v2-ui 面板
v2-ui status - 查看 v2-ui 状态
v2-ui enable - 设置 v2-ui 开机自启
v2-ui disable - 取消 v2-ui 开机自启
v2-ui log - 查看 v2-ui 日志
v2-ui update - 更新 v2-ui 面板
v2-ui install - 安装 v2-ui 面板
v2-ui uninstall - 卸载 v2-ui 面板
请参考 v2-ui 官方教程进行操作。
和原版一样,编辑配置文件:
nano /etc/v2ray/config.json
内容替换为:
{
"api": {
"services": [
"HandlerService",
"LoggerService",
"StatsService"
],
"tag": "api"
},
"inbounds": [
{
"listen": "127.0.0.1",
"port": 62789,
"protocol": "dokodemo-door",
"settings": {
"address": "127.0.0.1"
},
"tag": "api"
}
],
"outbounds": [{
"protocol": "socks",
"settings": {
"servers": [{
"address": "127.0.0.1",
"port": 7891,
"auth": "noauth"
}]
}
}],
"policy": {
"system": {
"statsInboundDownlink": true,
"statsInboundUplink": true
}
},
"routing": {
"rules": [
{
"inboundTag": [
"api"
],
"outboundTag": "api",
"type": "field"
},
{
"ip": [
"geoip:private"
],
"outboundTag": "blocked",
"type": "field"
},
{
"outboundTag": "blocked",
"protocol": [
"bittorrent"
],
"type": "field"
}
]
},
"stats": {}
}
上述内容同样也要替换入V2面板 Panel Settings 里的 v2ray config template 配置模板。
重启 V2Ray,让配置生效:
service v2ray restart
重启 v2-ui,让配置生效:
v2-ui restart
已有 2 条评论
这么做的好处是什么?
请问博主在么 问个问题 在吗?