apt install git curl build-essential libssl-dev zlib1g-dev
報錯:
Failed to fetch http://security.debian.org/debian-security/pool/updates/main/l/linux/linux-libc-dev_4.9.258-1_amd64.deb 404 Not Found [IP: 2a04:4e42:6a::644 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
解決方式:
apt-get update
git clone https://github.com/TelegramMessenger/MTProxy
cd MTProxy
make && cd objs/bin
注意,第一步的報錯不解決,這里會提示make not found
1、curl -s https://core.telegram.org/getProxySecret -o proxy-secret
2、curl -s https://core.telegram.org/getProxyConfig -o proxy-multi.conf
3、head -c 16 /dev/urandom | xxd -ps
./mtproto-proxy -u <用戶名,比如root> -p 8888 -H <端口號,比如443,如果443沒了,就隨便找個不重復(fù)到端口> -S <第三步生成的秘鑰> --aes-pwd proxy-secret proxy-multi.conf -M 1
解釋:所有尖括號里的內(nèi)容都要自行修改
這里執(zhí)行完后,會提示main loop表示已經(jīng)可用了。
tg://proxy?server=<你的域名或者IP>&port=<剛剛設(shè)置的端口號,443或者其他>&secret=<剛剛第三步生成的秘鑰>
進階:將程序服務(wù)化,重啟后自動啟動
nano /etc/systemd/system/MTProxy.service
官方推薦
我推薦:
vim /etc/systemd/system/MTProxy.service
然后將下面的值修改后拷貝進去:
[Unit]
Description=MTProxy
After=network.target
[Service]
Type=simple
WorkingDirectory=<你放mtproto-proxy程序的目錄,要是按照步驟一步步來,應(yīng)該就是在當前目錄,pwd命令執(zhí)行下,就顯示了>
ExecStart=<補全程序所在目錄>/mtproto-proxy -u <用戶名,比如root> -p 8888 -H <端口號,比如443,如果443沒了,就隨便找個不重復(fù)到端口> -S <第三步生成的秘鑰> --aes-pwd proxy-secret proxy-multi.conf -M 1
Restart=on-failure
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl restart MTProxy.service
systemctl status MTProxy.service
systemctl enable MTProxy.service
一般會在systemctl status MTProxy.service這里出現(xiàn)問題:
Active: active (running) 成功
Active: failed 失敗
排查問題順序:
先把MTProxy.service文件中的ExecStart這一行拷貝出來單獨執(zhí)行,看看能不能執(zhí)行
一般有3種問題:
端口被占用
使用到用戶名不存在
配置里到文件夾沒配置對,導(dǎo)致找不到命令。