TUIC-V5

手动搭建TUIC-V5服务

更新系统

1
apt -y update

安装申请证书的certbot

1
apt -y install wget certbot

安装服务端

新建文件夹并进入该文件夹

1
mkdir /opt/tuic && cd /opt/tuic

下载服务器端程序

下载获取服务端之前,可以先去 TUIC开发者的GitHub 查看一下服务端的版本,如有更新请替换下载地址!

1
wget wget https://github.com/EAimTY/tuic/releases/download/tuic-server-1.0.0/tuic-server-1.0.0-x86_64-unknown-linux-gnu -O /opt/tuic/tuic-server

给予服务器端程序权限

1
chmod +x /opt/tuic/tuic-server

配置服务端
这里要用到 nano 如果服务器系统没有安装,请自己安装

1
nano config.json

写入配置:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
{
    ”server“: ”[::]:14236“,
    ”users“: {
        ”3bec6d74-c8df-4a1f-aab2-7cd04f93c15d“: ”kU5elG3f4“
    },
    ”certificate“: ”/opt/tuic/fullchain.pem“,
    ”private_key“: ”/opt/tuic/privkey.pem“,
    ”congestion_control“: ”bbr“,
    ”alpn“: [”h3, ”spdy/3.1],
    ”udp_relay_ipv6“: true,
    ”zero_rtt_handshake“: false,
    ”auth_timeout“: 3s“,
    ”max_idle_time“: 10s“,
    ”max_external_packet_size“: 1500,
    ”gc_interval“: 3s“,
    ”gc_lifetime“: 15s“,
    ”log_level“: ”warn“
}

一些参数说明:

server“: ”[::]:14236“ 这里的端口 14236 可以自己修改成自己想设置的端口
users“: 这里前面是uuid,后面是密码,修改成自己的(uuid可以随便找一个在线网站生成) 其他参数一般不需要修改
建立systemd配置文件

1
nano /lib/systemd/system/tuic.service

写入配置:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
[Unit]
Description=Delicately-TUICed high-performance proxy built on top of the QUIC protocol
Documentation=https://github.com/EAimTY/tuic
After=network.target

[Service]
User=root
WorkingDirectory=/opt/tuic
ExecStart=/opt/tuic/tuic-server -c config.json
Restart=on-failure
RestartPreventExitStatus=1
RestartSec=5

[Install]
WantedBy=multi-user.target

如果有证书的就直接把证书放到/opt/tuic 文件夹里按照上面的配置公钥修改命名为:fullchain.pem,私钥修改命名为:private.pem 那么就已经完成了。如果没有就通过certbot申请证书

申请证书

1
2
3
4
5
6
certbot certonly \
—standalone \
—agree-tos \
—no-eff-email \
—email [email protected] \
-d your.com

注意:把里面的:[email protected] 换成你的邮箱,your.com 换成你的域名
将获得的证书放到服务器配置文件夹内的位置:(把里面的your.com换成你自己的域名)

1
cat /etc/letsencrypt/live/your.com/fullchain.pem > /opt/tuic/fullchain.pem
1
cat /etc/letsencrypt/live/your.com/privkey.pem > /opt/tuic/privkey.pem

启动tuic服务并设置开机自启

1
systemctl enable —now tuic.service

证书自动续期:

1
nano /etc/letsencrypt/renewal-hooks/post/tuic.sh

写入如下内容:
注意:把里面的 your.com 换成你自己的域名

1
2
3
4
#!/bin/bash
cat /etc/letsencrypt/live/your.com/fullchain.pem > /opt/tuic/fullchain.pem
cat /etc/letsencrypt/live/your.com/privkey.pem > /opt/tuic/privkey.pem
systemctl restart tuic.service

给脚本执行权限

1
cd /etc/letsencrypt/renewal-hooks/post
1
chmod +x tuic.sh

测试续期的情况以及脚本能否正常运行:(里面的 your.com 换成你自己的域名)

1
certbot renew —cert-name your.com —dry-run

重启

1
systemctl restart tuic

查看服务器状态

1
systemctl status tuic

卸载

1
systemctl stop tuic && systemctl disable —now tuic.service && rm -rf /opt/tuic

surge客户端配置

surge客户端配置可以直接在UI填写服务端配置信息就可以了

一些配置参数说明:

代理类型TUIC-V5
服务器地址:你自己VPS的IP地址
端口号14236 端口号就是上面config.json里面 ”server“: ”[::]:14236“ 设置的端口
UUID3bec6d74-c8df-4a1f-aab2-7cd04f93c15d 就是config.json里面user部分的前面部分 ”3bec6d74-c8df-4a1f-aab2-7cd04f93c15d“: ”kU5elG3f4“
密码kU5elG3f4 密码,就是config.json里面user部分后面的 ”3bec6d74-c8df-4a1f-aab2-7cd04f93c15d“: ”kU5elG3f4
Custom SNI:你自己申请证书的域名
ALPNh3

最后更新于 May 24, 2024 00:00 UTC
使用 Hugo 构建
主题 StackJimmy 设计