手动搭建TUIC v5

2,977次阅读
12 条评论

共计 3443 个字符,预计需要花费 9 分钟才能阅读完成。

折腾前需要准备的:最新版 TF 版的 surge,并且订阅没有过期;有一个 vps,有一个属于你的域名

建立服务端

进入 ssh,输入指令获取管理员权限

sudo -i

然后依次输入:

升级服务器

apt -y update

获取申请证书的 certbot

apt -y install wget certbot

建立服务器端的文件夹并进入该文件夹

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

获取服务器端程序:
因为最近作者一直在更新,版本更新比较快,所以去 作者的库 查看下最新版

X86

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

ARM

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

赋予服务器端程序权限:

X86

chmod +x /opt/tuic/tuic-server

ARM

chmod +x /opt/tuic/tuic-server

这里每一行是一条指令,输入后按回车等执行完再进行下一条命令

建立服务器端配置:

nano config.json

(有些 vps 可能默认没有 nano,那么就需要安装 nano 了,具体的方式可以自行搜索:nano 安装)

写入如下配置:

{"server": "[::]:52408",
    "users": {"8e21e704-9ac8-4fb8-bef1-6c9d7d7e390b": "RnJ5BfJ3"},
    "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"
}

新建 systemd 配置文件

nano /lib/systemd/system/tuic.service

写入如下配置:

X86:

[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

ARM

[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

至此其实服务器端已经建立好了。如果你已经之前玩过 trojan 有证书的话就直接把证书放入到 /opt/tuic 文件夹里按照上面的配置公钥命名为:fullchain.pem,私钥命名为:private.pem 那么就已经完成了。如果没有的话就接着往下看,通过 certbot 申请证书吧

申请证书:

certbot certonly \
--standalone \
--agree-tos \
--no-eff-email \
--email [email protected] \
-d your.com

这里注意就是要把整个指令先复制到其它文本编辑器里面,把里面的:[email protected] 换成你的邮箱,your.com 换成你的域名,换好后再复制到 ssh app 里面按下回车执行

将获得的证书放到服务器配置文件内的位置:(把里面的 your.com 换成你自己的域名)

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

注意上面是两条指令,分别执行。

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

systemctl enable --now tuic.service

至此服务器端的配置已经全部完成了。你在 surge 配置里面就可以按照老刘提供的格式进行节点设置了, 如下示意配置格式,1.1.1.1 换成你的 vps 的 IP,端口就是上面 config.json 里面设置的端口,password 后面就是里面设置的密码,sni 后面就是你的域名,uuid 就是 config.json 里面 user 部分,可以自己去通过相应工具生成。
最新版的 surge 已经可以通过 UI 添加。参照填入即可


TUIC V5 = tuic, 1.1.1.1 , 52408, skip-cert-verify=true, sni=your.com, uuid=8e21e704-9ac8-4fb8-bef1-6c9d7d7e390b, alpn=h3, password=RnJ5BfJ3, version=5

可以用下面命令获取证书指纹,在 surge 里面进行证书锁定,来进一步确保安全性。

openssl x509 -noout -fingerprint -sha256 -inform pem -in /opt/tuic/fullchain.pem

因为 certbot 申请的证书有期限,所以设置个自动运行的脚本进行自动续期

新建一个 certbot 的 hook 脚本文件,用于让 tuic 重新加载续期后的新证书:

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

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

#!/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

给脚本执行权限:

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

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

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

至此服务器端就全部配置完成了。

重启:

systemctl restart tuic

如果想查看服务器状态,用这个指令

systemctl status tuic

卸载:

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

更多资源请  点击这里  关注 TG 频道
正文完
 
lucky
版权声明:本站原创文章,由 lucky 2023-07-02发表,共计3443字。
转载说明:转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(12 条评论)
2024-05-22 20:03:04 回复

Thanks for sharing. I read many of your blog posts, cool, your blog is very good.

 Windows  Edge  美国加利福尼亚旧金山
2024-06-24 10:04:51 回复

Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?

 Windows  Edge  拉脱维亚Riga
2024-08-07 16:16:28 回复

purchase lasuna for sale – himcolin brand himcolin medication

 Windows  Chrome  拉脱维亚Riga
2024-08-20 09:47:20 回复

generic besivance – sildamax for sale online sildamax pills

 Windows  Chrome  美国加利福尼亚旧金山
2024-08-22 07:17:11 回复

gabapentin where to buy – order gabapentin 600mg generic brand azulfidine 500mg

 Windows  Chrome  美国加利福尼亚旧金山
2024-08-25 01:55:14 回复

buy cheap benemid – buy etodolac without prescription carbamazepine price

 Windows  Chrome  美国加利福尼亚旧金山
2024-08-26 20:46:55 回复

priligy price Initial treatment strategies must include lifestyle modifications, including dietary changes, tobacco cessation, weight loss, increased physical activity, and decreased alcohol intake

 Windows  Chrome  美国加利福尼亚旧金山
2024-08-27 22:25:04 回复

order celecoxib 200mg generic – buy celebrex 200mg sale order indocin 75mg generic

 Windows  Chrome  美国加利福尼亚旧金山
2024-08-29 10:45:06 回复

oral colospa – etoricoxib 60mg without prescription cilostazol 100 mg without prescription

 Windows  Chrome  巴西圣保罗圣保罗
2024-09-01 05:39:21 回复

If such effects occur, reduce the dose of TRELEGY ELLIPTA slowly, consistent with accepted procedures for reducing systemic corticosteroids, and consider other treatments for management of COPD or asthma symptoms priligy review youtube

 Windows  Chrome  美国加利福尼亚旧金山
2024-09-01 22:19:24 回复

voltaren for sale – purchase voltaren pills order aspirin 75 mg for sale

 Windows  Chrome  美国加利福尼亚旧金山
2024-09-07 08:07:24 回复

order rumalaya for sale – order generic rumalaya amitriptyline 10mg oral

 Windows  Chrome  美国加利福尼亚旧金山