How to Set Up MTProto Proxy for Telegram on Ubuntu 22.04

Estimated reading: 2 minutes 19 views

Introduction

MTProxy is Telegram’s official proxy solution that helps users bypass network restrictions while maintaining secure connections. This comprehensive guide will walk you through the server setup process and show you how to connect via Telegram clients.

Server Installation

1. SSH into your server

ssh root@your_server_ip

2. Update system and install dependencies

sudo apt-get update -y
sudo apt install git curl build-essential libssl-dev zlib1g-dev -y

3. Clone the MTProxy repository

We recommend using the community-maintained fork for better reliability:

git clone https://github.com/GetPageSpeed/MTProxy
cd MTProxy

4. Modify the Makefile

Add -fcommon flag to both COMMON_CFLAGS and COMMON_LDFLAGS:

nano Makefile

5. Compile MTProxy

make

6. Install the binary

sudo mkdir /opt/MTProxy
sudo cp objs/bin/mtproto-proxy /opt/MTProxy/
cd /opt/MTProxy

7. Download configuration files

sudo curl -s https://core.telegram.org/getProxySecret -o proxy-secret
sudo curl -s https://core.telegram.org/getProxyConfig -o proxy-multi.conf

8. Generate your secret key

head -c 16 /dev/urandom | xxd -ps

Save this output for later use.

9. Create dedicated user

sudo useradd -m -s /bin/false mtproxy
sudo chown -R mtproxy:mtproxy /opt/MTProxy

10. Configure firewall

sudo ufw allow 8443/tcp

11. Set up systemd service

Create service file:

sudo nano /etc/systemd/system/MTProxy.service

Paste this configuration (replace placeholders with your actual values):

[Unit]
Description=MTProxy
After=network.target

[Service]
Type=simple
WorkingDirectory=/opt/MTProxy
ExecStart=/opt/MTProxy/mtproto-proxy -u mtproxy -p 8888 -H 8443 -S <YOUR_SECRET STEP 8> --aes-pwd proxy-secret proxy-multi.conf -M 1
Restart=on-failure

[Install]
WantedBy=multi-user.target

12. Start the service

sudo systemctl daemon-reload
sudo systemctl restart MTProxy.service
sudo systemctl status MTProxy.service

Connecting via Telegram

Method 1: Direct link connection

Create a connection link in this format:

tg://proxy?server=<SERVER_IP>&port=8443&secret=<SECRET_KEY>

Open this link directly in your mobile browser or share it through any app.

Method 2: Manual proxy configuration

  1. Open Telegram app

  2. Go to Settings > Data and Storage > Proxy Settings

  3. Tap “Add Proxy”

  4. Enter:

  • Server: Your server IP/domain
  • Port: 8443
  • Secret: Your generated secret key (step 8)

5.Tap “Save” and enable the proxy

Conclusion

You’ve successfully deployed a high-performance MTProxy server for Telegram. This solution provides:

  • Reliable bypassing of network restrictions

  • Secure encrypted connections

  • Better accessibility in restricted regions

For optimal performance, consider setting up a domain name with SSL instead of using raw IP addresses.

Share this Doc

How to Set Up MTProto Proxy for Telegram on Ubuntu 22.04

Or copy link

CONTENTS