Featured image of post 使用mtg搭建mtp代理

使用mtg搭建mtp代理

前言

项目地址:9seconds/mtg: Highly opinionated MTPROTO proxy for Telegram

貌似是我现在能找到的最好的一个搭建mtp代理的项目,用着还不错,就写(shui)一篇教程~

下载mtg

这里使用的是二进制文件,版本为v2.1.6 版本,也可以自行去github下载

1
2
3
wget https://blog.gezi.men/file/mtg
chmod +x mtg
mv mtg /usr/local/bin/

生成密钥

可以自行设置baidu.com为自己需要伪装的域名

1
mtg generate-secret baidu.com

假如生成的密钥为:7rW9y2SrRa2fNWV3Ara4gIBiYWlkdS5jb20(请使用自己生成的密钥)

配置文件

1
vim /etc/mtg.toml

内容如下:

1
2
secret = "7rW9y2SrRa2fNWV3Ara4gIBiYWlkdS5jb20"
bind-to = "0.0.0.0:443"
  • secret:填写刚刚生成的密钥
  • bind-to:端口号自行设置

开机自启

将mtg加入到服务中,设置开机自启

1
vim /etc/systemd/system/mtg.service

内容如下:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
[Unit]
Description=mtg - MTProto proxy server
Documentation=https://github.com/9seconds/mtg
After=network.target

[Service]
ExecStart=/usr/local/bin/mtg run /etc/mtg.toml
Restart=always
RestartSec=3
DynamicUser=true
AmbientCapabilities=CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target

重载服务配置、服务开机自启、启动服务、查看服务状态(复制粘贴一条龙服务,乐):

1
2
3
4
systemctl daemon-reload
systemctl enable mtg
systemctl start mtg
systemctl status mtg

服务状态显示 active (running)便可以正常使用了!

生成相应的链接

1
mtg access /etc/mtg.toml
Licensed under CC BY-NC-SA 4.0
最后更新于 Apr 30, 2022 02:54 CST
comments powered by Disqus
Built with Hugo
主题 StackJimmy 设计