How to setup a Telegram MTProto Proxy

How to setup a Telegram MTProto Proxy

Equipe @DicasTelegram

So you want to setup your own proxy to help Telegram users that live in countries without digital freedom (like Iran, Russia and some others)?

Follow the instructions bellow:

First of all, make sure you have the development packages installed in your distribution (in my example, a Debian distribution): build-essential, libssl-dev and libz-dev.

1. Clone repository

git clone https://github.com/TelegramMessenger/MTProxy.git

2. To build, run the make && cd objs/bin command inside MTProxy folder (created above). Your binary will be  located in objs/bin/mtproto-proxy.

3. Obtain a secret, used to connect to telegram servers.

curl -s https://core.telegram.org/getProxySecret -o proxy-secret

4. Obtain current telegram configuration. It can change (occasionally), so we encourage you to update it once per day.

curl -s https://core.telegram.org/getProxyConfig -o proxy-multi.conf

5. Generate a secret to be used by users to connect to your proxy

head -c 16 /dev/urandom | xxd -ps

6. Run mtproto-proxy

mtproto-proxy -u nobody -p 8888 -H 443 -S --aes-pwd proxy-secret proxy-multi.conf -M 1 -P

Where:

  • nobody is the actual username. mtproto-proxy calls setuid() to drop privilegies;
  • 443 is the port, used by clients to connect to the proxy;
  • 8888 is the local port;
You can use the local port to get statistics from mtproto. Like wget localhost:8888/stats - only via loopback
  • is the secret generated at step 5;
  • proxy-secret and proxy-multi.conf are obtained at steps 3 and 4;
  • 1 is the number of workers. You can increase the number of workers, if you have a powerful server;
  • is the tag informed by @MTProxybot when you set a sponsored channel;
  • also feel free to check out other options using mtproto-proxy help.

7. Generate the link as tg://proxy?server=SERVER_NAME&port=443&secret=SECRET

8. Register your proxy with @MTProxybot on Telegram

9. Enjoy! 😁👍

Did you like this tutorial? Share on Twitter!

Assine @DicasTelegram!

Report Page