Sign inSign up

aleksandrborodavkin/mtproxy

By aleksandrborodavkin

Updated 7 months ago

MTProxy from Telegram source. Runtime image.

Image
Networking
0

330

aleksandrborodavkin/mtproxy repository overview

Docker image for MTProxy (Telegram MTProto proxy), built from the official TelegramMessenger/MTProxy source. Runtime-only image — no compilation inside the container.

Usage

docker run -d -p 443:443 \
  -v mtproxy-data:/data \
  -e SECRET=your_32_hex_char_secret \
  -e TAG=your_32_hex_tag \
  aleksandrborodavkin/mtproxy:0.02
Environment variables
VariableRequiredDescription
SECRETYes32 hex characters (16 bytes). Generate: head -c 16 /dev/urandom | xxd -ps
TAGNo32 hex proxy tag from @MTProxybot
WORKERSNoNumber of workers (default: 2)
Example .env
# MTProto Proxy
SECRET=your_32_hex_char_secret_here
TAG=your_32_hex_tag_from_mtproxybot
WORKERS=2

Use your own values: generate SECRET with head -c 16 /dev/urandom | xxd -ps, get TAG from @MTProxybot after registering the proxy.

Volumes
  • /data — proxy config (proxy-secret, proxy-multi.conf). Fetched from Telegram on first run if missing.
Ports
  • 443 — client connection port

Docker Compose

services:
  mtproxy:
    image: aleksandrborodavkin/mtproxy:0.02
    restart: always
    ports:
      - "443:443"
    volumes:
      - proxy-config:/data
    env_file:
      - .env

volumes:
  proxy-config:

Create a .env file in the same directory (see Example .env above).

How this image was built

Binary is built from source on the host; the image only adds runtime and entrypoint (no build inside Docker).
Runtime base image: debian:trixie-slim (glibc ≥ 2.38, currently 2.41).

1. Build MTProxy binary:

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

2. Create Dockerfile (runtime-only, debian:trixie-slim):

FROM debian:trixie-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
    ca-certificates \
    curl \
    && rm -rf /var/lib/apt/lists/*
COPY mtproto-proxy /usr/local/bin/mtproto-proxy
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
EXPOSE 443
ENTRYPOINT ["/entrypoint.sh"]

3. Create entrypoint.sh:

#!/bin/sh
set -e

DATA_DIR="${DATA_DIR:-/data}"
mkdir -p "$DATA_DIR"
cd "$DATA_DIR"

# Download Telegram proxy config if not present (persisted in /data volume)
if [ ! -f proxy-secret ] || [ ! -f proxy-multi.conf ]; then
  curl -sf https://core.telegram.org/getProxySecret -o proxy-secret
  curl -sf https://core.telegram.org/getProxyConfig -o proxy-multi.conf
fi

if [ -z "$SECRET" ]; then
  echo "Error: SECRET environment variable is required (32 hex chars)" >&2
  exit 1
fi

WORKERS="${WORKERS:-2}"
ARGS="-u nobody -p 8888 -H 443 -S $SECRET --aes-pwd $DATA_DIR/proxy-secret $DATA_DIR/proxy-multi.conf -M $WORKERS"
[ -n "$TAG" ] && ARGS="$ARGS -P $TAG"

exec mtproto-proxy $ARGS

4. Copy binary and build:

cp MTProxy/objs/bin/mtproto-proxy .
docker build -t aleksandrborodavkin/mtproxy:0.02 .

Tag summary

Content type

Image

Digest

sha256:96e17a383

Size

34.6 MB

Last updated

7 months ago

docker pull aleksandrborodavkin/mtproxy:0.02