DEV Community

Set proxy
Set proxy

Posted on • Originally published at telegra.ph

Complete Guide to Setting Up Telegram MTProto Proxy

Complete Guide to Setting Up Telegram MTProto Proxy

Telegram MTProto proxies are lightweight, secure relays that bypass network restrictions while maintaining end-to-end encryption. Unlike standard SOCKS or HTTP proxies, MTProto is Telegram’s proprietary transport protocol, optimized for speed and resilience against deep packet inspection. This guide covers setup for both users and server operators, with a focus on Frankfurt, Germany—a key European hub for low-latency connectivity.

Why Use an MTProto Proxy?

MTProto proxies offer three critical advantages:

  1. Obfuscation – Traffic signatures mimic normal HTTPS, evading censorship.
  2. No logging – Proxies cannot decrypt messages (only metadata routing).
  3. Lightweight deployment – A minimal VPS (256 MB RAM) can handle thousands of users.

Frankfurt’s DE-CIX internet exchange provides peering with major European ISPs, reducing ping to ~10–30 ms for regional users.

Setting Up the MTProto Proxy Server (Frankfurt VPS)

Prerequisites

  • A Linux VPS in Frankfurt (e.g., Hetzner, Netcup) with a public IPv4 address.
  • Root access (Ubuntu 20.04+ or Debian 11+ recommended).

Step 1: Install Dependencies

sudo apt update && sudo apt install git curl build-essential -y
Enter fullscreen mode Exit fullscreen mode

Step 2: Clone the Official MTProto Proxy Script

git clone https://github.com/TelegramMessenger/MTProxy
cd MTProxy
make
Enter fullscreen mode Exit fullscreen mode

Step 3: Generate Configuration

# Generate random secret (32 hex characters)
echo $(hexdump -n 16 -e '4/4 "%08X" 1 "\n"' /dev/urandom) > secret.txt
Enter fullscreen mode Exit fullscreen mode

Step 4: Start the Proxy

sudo ./objs/bin/mtproto-proxy -p 8888 -H 443 -S "$(cat secret.txt)" --http-ports 80 -M 1
Enter fullscreen mode Exit fullscreen mode
  • -p 8888: Local admin port for monitoring.
  • -H 443: Fake TLS handshake port (disguises as HTTPS).
  • -S: Secret key for authentication.
  • --http-ports 80: Additional support for HTTP proxies.
  • -M 1: Single worker thread (increase for high traffic).

Step 5: Configure Firewall

sudo ufw allow 443/tcp
sudo ufw allow 80/tcp
Enter fullscreen mode Exit fullscreen mode

Connecting to Your Proxy in Telegram

Mobile (Android/iOS)

  1. Go to Settings > Data and Storage > Proxy Settings > Add Proxy.
  2. Select MTProto and enter:
    • Server: Your Frankfurt VPS IP
    • Port: 443
    • Secret: Paste the hex secret from secret.txt

Desktop (Windows/macOS/Linux)

  • Open Telegram, click Settings > Advanced > Connection Type > Use custom proxy.
  • Choose MTProto, input the same IP, port, and secret.

Testing & Optimization

Monitor usage via the admin port:

curl http://localhost:8888/stats
Enter fullscreen mode Exit fullscreen mode

Look for connected_sessions and bandwidth. For Frankfurt servers, expect <20 ms latency from Western Europe.

To run persistently, create a systemd service:

sudo nano /etc/systemd/system/mtproxy.service
Enter fullscreen mode Exit fullscreen mode

Paste:

[Unit]
Description=MTProto Proxy
[Service]
ExecStart=/root/MTProxy/objs/bin/mtproto-proxy -p 8888 -H 443 -S $(cat /root/MTProxy/secret.txt) --http-ports 80 -M 1
Restart=always
[Install]
WantedBy=multi-user.target
Enter fullscreen mode Exit fullscreen mode

Enable with sudo systemctl enable --now mtproxy.

Security Notes

  • Rotate secrets monthly via tr -dc 'A-F0-9' < /dev/urandom | head -c 32.
  • Use fail2ban to block brute-force attacks on port 443.
  • Never expose your admin port (8888) publicly.

Get free proxies at t.me/SetProxy.

Top comments (0)