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

MTProto proxy is a lightweight protocol designed by Telegram to bypass censorship and improve connection stability. Unlike standard SOCKS5 proxies, MTProto proxies integrate directly with Telegram’s encryption layer, making them harder to detect and block. This guide covers setup for both users and administrators, with a focus on deployment in Frankfurt, Germany—a strategic location offering low latency to Europe, Asia, and North America due to its Tier-1 network connectivity.

For Users: Connecting via an MTProto Proxy

  1. Obtain a Proxy Link: You’ll need a URL in the format https://t.me/proxy?server=IP&port=PORT&secret=SECRET. This link contains all connection parameters.
  2. Open in Telegram: On your mobile or desktop app, tap or click the link. Telegram will automatically prompt you to enable the proxy.
  3. Manual Setup (optional): Go to Settings > Data and Storage > Proxy Settings. Tap “Add Proxy,” select “MTProto,” and enter the server IP (e.g., 123.45.67.89), port (e.g., 443), and secret (a 32-character hex string). Save and toggle the proxy on.
  4. Verify Connection: Send a message or load a channel. If it works, the proxy is active. You can test by checking your IP via Telegram’s “Privacy and Security” menu—look for a non-blocked region.

For Administrators: Hosting an MTProto Proxy in Frankfurt

Hosting your own proxy gives you control over speed and security. Frankfurt (DE) is ideal due to its internet exchange (DE-CIX) and support for cheap, high-bandwidth VPS providers like Hetzner or Contabo.

Prerequisites:

  • A Linux VPS (Ubuntu 22.04 or Debian 12 recommended) with a static IP.
  • Ports open (typically 443 or 80 for obfuscation).
  • Python 3.6+ or Docker installed.

Step-by-Step Deployment:

  1. SSH into your server:
   ssh root@your_frankfurt_vps_ip
Enter fullscreen mode Exit fullscreen mode
  1. Install the MTProto proxy script (official Telegram version):
   git clone https://github.com/TelegramMessenger/MTProxy
   cd MTProxy
   make
Enter fullscreen mode Exit fullscreen mode
  1. Generate a secret key:
   head -c 16 /dev/urandom | xxd -ps
Enter fullscreen mode Exit fullscreen mode

Copy the 32-character output (e.g., a1b2c3d4e5f6789012345678abcdef90).

  1. Run the proxy:
   ./mtproto-proxy -p 443 -H 443 -S YOUR_SECRET -P 0 0.0.0.0
Enter fullscreen mode Exit fullscreen mode

Adjust -p (client port) and -H (fake TLS port) if needed.

  1. Create the proxy link:
   https://t.me/proxy?server=YOUR_VPS_IP&port=443&secret=YOUR_SECRET
Enter fullscreen mode Exit fullscreen mode

Share this link with users.

Optimization Tips for Frankfurt:

  • Use iptables to limit connections (e.g., 100 per IP) and prevent abuse.
  • Monitor logs with journalctl -u mtproxy to detect throttling.
  • For high traffic, consider a reverse proxy with Nginx and TLS termination—but MTProto already handles encryption.

Troubleshooting:

  • “Connection failed” often means the port is firewalled. Check ufw status and allow 443.
  • Slow speeds? Upgrade to a VPS with 1 Gbps uplink (Hetzner offers €4/month plans).
  • Secret invalid? Re-run the xxd command—ensure no line breaks.

MTProto proxies are a robust way to ensure Telegram access in restrictive regions. For a quick start without self-hosting, test a pre-configured proxy from a reputable provider.

Get free proxies at t.me/SetProxy.

Top comments (0)