mtprotoproxy Documentation

repository·master·Indexed 24 days ago

https://github.com/alexbers/mtprotoproxy

A fast and simple MTProto proxy written in Python for Telegram users. It supports Docker deployment, channel advertising via AD_TAG, high-concurrency performance with uvloop, and runtime statistics export to Prometheus.

Tokens
775
Snippets
3
Records
5
Agent score
30%

What's inside mtprotoproxy

  1. Quickstart: Set up the MTProto Proxy

    master

    To deploy the MTProto proxy, clone the stable branch, configure your settings, and run it using Docker or Python.

    1. Clone the repository:
      git clone -b stable https://github.com/alexbers/mtprotoproxy.git; cd mtprotoproxy
    2. (Optional but recommended) Edit config.py to set your PORT, USERS, and AD_TAG.
    3. Start the proxy:
      • Using Docker: docker-compose up -d
      • Using Python: python3 mtprotoproxy.py
    4. (Optional) Retrieve the proxy link to share with users by checking the logs: docker-compose logs.
    git clone -b stable https://github.com/alexbers/mtprotoproxy.git; cd mtprotoproxy
    # Edit config.py then:
    docker-compose up -d
  2. Deploy MTProto Proxy using Docker Compose

    master

    You can deploy the MTProto Proxy using a docker-compose.yml file. The configuration uses network_mode: "host" to allow the proxy to bind directly to host ports, which is often necessary for MTProto traffic.

    To run the service, ensure you have the required configuration and source files in the same directory as the compose file, as they are mounted as volumes.

    version: '2.0'
    services:
      mtprotoproxy:
        build: .
        restart: unless-stopped
        network_mode: "host"
        volumes:
            - ./config.py:/home/tgproxy/config.py
            - ./mtprotoproxy.py:/home/tgproxy/mtprotoproxy.py
            - /etc/localtime:/etc/localtime:ro
        logging:
            driver: "json-file"
            options:
                max-file: "10"
                max-size: "10m"
  3. Configure Docker Compose volumes for MTProto Proxy

    master

    The Docker Compose setup requires specific files to be mounted into the container to function correctly. The following volume mappings are used:

    • ./config.py must be mapped to /home/tgproxy/config.py (contains proxy settings).
    • ./mtprotoproxy.py must be mapped to /home/tgproxy/mtprotoproxy.py (the application logic).
    • /etc/localtime is mapped as read-only (ro) to ensure the container uses the host's system time.
  4. Advanced Launch Options for mtprotoproxy.py

    master

    The proxy script supports several advanced execution modes:

    • Custom Configuration: Pass a specific configuration file as an argument.
    • Load Balancing: You can run multiple instances of the proxy; clients will be automatically balanced between them.
    • Performance Boost: Use the uvloop module to increase execution speed.
    • Monitoring: The proxy supports exporting runtime statistics to Prometheus.
    python3 mtprotoproxy.py [configfile]