gitmyhub

MTProxy

C ★ 6.9k updated 7mo ago

MTProxy is a proxy server built by Telegram for the MT-Proto protocol, which is the protocol Telegram uses for its messaging app. Running this proxy lets people connect to Telegram through your server, which is useful in regions where direct access to Telegram is restricted by internet service providers or governments.

Setup involves compiling the code from source, which requires common build tools plus development libraries for OpenSSL and zlib. These are standard packages available through the package manager on any Linux system. The build process is a single make command.

Running the proxy involves a few steps. First, you download a secret file and a configuration file from Telegram's servers. These files authenticate your proxy with Telegram and tell it how to route traffic. Then you generate a secret string that your users will need when connecting. The proxy runs on a port you choose (commonly 443, the standard HTTPS port), and you can run multiple worker processes if your server is powerful enough.

Once the proxy is running, you share a connection link with users and register the proxy with Telegram's official bot on the platform. Telegram provides a local statistics endpoint so you can monitor usage. The proxy can also be configured as a long-lived background service using systemd, with automatic restart on failure and automatic start on reboot.

There is a random padding option that adds random bytes to message packets to make them harder to identify by size-based traffic inspection, which some internet providers use to block Telegram connections. This mode is enabled by adding "dd" to the secret string on the client side. Telegram also publishes an official Docker image for the proxy, though the README notes it may be outdated.