MTProxy Documentation

repository·master·Indexed 27 days ago

https://github.com/telegrammessenger/mtproxy

MTProxy is a simple MT-Proto proxy designed to facilitate Telegram connections, featuring random padding to evade ISP detection. This documentation covers building from source, running the mtproto-proxy binary, CLI options reference, systemd service configuration, and the official Docker image.

Tokens
942
Snippets
3
Records
5
Agent score
42%

What's inside MTProxy

  1. Configure MTProxy as a Systemd service

    master

    To run MTProxy as a background service on Linux, create a systemd service file at /etc/systemd/system/MTProxy.service. After creating the file, reload the daemon, start the service, and enable it for autostart on reboot.

    # 1. Create the service file
    # File content for /etc/systemd/system/MTProxy.service:
    [Unit]
    Description=MTProxy
    After=network.target
    
    [Service]
    Type=simple
    WorkingDirectory=/opt/MTProxy
    ExecStart=/opt/MTProxy/mtproto-proxy -u nobody -p 8888 -H 443 -S <secret> -P <proxy tag> <other params>
    Restart=on-failure
    
    [Install]
    WantedBy=multi-user.target
    
    # 2. Apply changes
    systemctl daemon-reload
    systemctl restart MTProxy.service
    systemctl enable MTProxy.service
  2. Run mtproto-proxy

    master

    To run the proxy, you need to perform several preparation steps:

    1. Download the Telegram server secret using curl -s https://core.telegram.org/getProxySecret -o proxy-secret.
    2. Download the current Telegram configuration using curl -s https://core.telegram.org/getProxyConfig -o proxy-multi.conf.
    3. Generate a 16-byte hex secret for users using head -c 16 /dev/urandom | xxd -ps.

    Then, execute the binary with the required flags. To enable random padding (to evade ISP detection), prefix your user secret with dd (e.g., dd<secret>).

    ./mtproto-proxy -u nobody -p 8888 -H 443 -S <secret> --aes-pwd proxy-secret proxy-multi.conf -M 1
  3. Build MTProxy from source

    master

    To build MTProxy, you must first install the necessary development dependencies for openssl and zlib. After cloning the repository, use make to compile the binary. The resulting binary will be located in objs/bin/mtproto-proxy. If a build fails, run make clean before attempting to build again.

    # On Debian/Ubuntu
    apt install git curl build-essential libssl-dev zlib1g-dev
    
    # On CentOS/RHEL
    yum install openssl-devel zlib-devel
    yum groupinstall "Development Tools"
    
    # Build process
    git clone https://github.com/TelegramMessenger/MTProxy
    cd MTProxy
    make && cd objs/bin
  4. mtproto-proxy CLI options reference

    master

    The mtproto-proxy binary accepts the following command-line arguments:

    • -u <username>: The username to use when calling setuid() to drop privileges (e.g., nobody).
    • -p <port>: The local port used to retrieve statistics via loopback (e.g., wget localhost:8888/stats).
    • -H <port>: The port used by clients to connect to the proxy.
    • -S <secret>: The secret used by clients to connect. You can specify multiple secrets by repeating this flag.
    • -P <proxy tag>: The proxy tag received from @MTProxybot.
    • --aes-pwd <file>: Path to the file containing the secret obtained from Telegram servers.
    • <config_file>: Path to the Telegram configuration file (proxy-multi.conf).
    • -M <number>: The number of worker processes to spawn.