MTProxyHub
All posts
9 min

How to Install MTProxy on a VPS: Step-by-Step Guide

A complete guide to installing MTProxy on a Linux server: choosing a VPS, installing via apt and from source, configuring the firewall, Fake TLS, and autostart.

How to Install MTProxy on a VPS: Step-by-Step Guide

Setting up your own MTProxy server takes 30 minutes of work and $3–5 a month for a VPS. In return, you get a proxy that works only for you, does not slow down from overload, and does not push someone else's channels. In this article, we break down the process from choosing a server to the first connection.

If you want the Docker variant (faster and easier to manage), read the separate guide. Here is the installation without Docker, directly on the system.

Step 1: Choosing and Renting a VPS

MTProxy does not require powerful servers. Minimum requirements:

ParameterMinimumRecommended
CPU1 core1–2 cores
RAM256 MB512 MB – 1 GB
Disk space5 GB10 GB SSD
OSUbuntu 22.04Ubuntu 22.04 LTS
LocationOutside the blocked countryNetherlands, Finland, Germany

Recommended providers:

  • Hetzner — from €3.79/mo, excellent reputation, EU data centers
  • DigitalOcean — from $4/mo, wide geography, user-friendly interface
  • Vultr — from $2.50/mo, many locations, hourly billing

After registering, create a VPS with Ubuntu 22.04 and obtain SSH access.

Step 2: Initial Server Setup

Connect via SSH:

ssh root@YOUR_IP

Update the system:

apt update && apt upgrade -y

Open port 443 (recommended for Fake TLS):

ufw allow 443/tcp
ufw allow 22/tcp    # mandatory, otherwise you will lose SSH access
ufw enable

Step 3: Installation via Official Package

The easiest way on Debian/Ubuntu is to use a ready-made installer script from the community. It automatically clones the repository, compiles, and configures the systemd unit:

curl -L https://git.io/mtpinstall -o mtpinstall.sh
# Check the contents before running!
cat mtpinstall.sh
bash mtpinstall.sh

Important: Always check the contents of scripts before running them as root. If you don't trust ready-made installers, use the Docker variant or build from source (next section).

Step 4: Building from Source

This is the most transparent method. You know exactly what you are running.

Install dependencies for compilation:

apt install -y git build-essential libssl-dev zlib1g-dev

Clone the official repository:

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

Build:

make

The binary will appear at objs/bin/mtproto-proxy.

Step 5: Generating Secret and Configuration

Generate a random key:

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

For Fake TLS (recommended):

KEY=$(head -c 16 /dev/urandom | xxd -ps)
DOMAIN_HEX=$(echo -n "google.com" | xxd -p)
SECRET="ee${KEY}${DOMAIN_HEX}"
echo "Your secret: $SECRET"

Get the list of current Telegram server IP ranges:

curl -s https://core.telegram.org/getProxyConfig -o proxy-secret
curl -s https://core.telegram.org/getProxyMultiConfig -o proxy-multi-secret

Step 6: Running MTProxy

./objs/bin/mtproto-proxy \
  -u nobody \
  -p 8888 \
  -H 443 \
  -S "$SECRET" \
  --aes-pwd proxy-secret proxy-multi-secret \
  -M 1 \
  &

Parameters:

  • -p 8888 — internal management port
  • -H 443 — public port (the one opened in the firewall)
  • -S — your secret
  • -M 1 — number of workers

Step 7: Configuring Autostart via systemd

Create a unit file:

cat > /etc/systemd/system/mtproxy.service << 'EOF'
[Unit]
Description=MTProxy
After=network.target

[Service]
Type=simple
WorkingDirectory=/root/MTProxy
ExecStart=/root/MTProxy/objs/bin/mtproto-proxy \
  -u nobody -p 8888 -H 443 \
  -S YOUR_SECRET \
  --aes-pwd /root/MTProxy/proxy-secret /root/MTProxy/proxy-multi-secret \
  -M 1
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable mtproxy
systemctl start mtproxy

Check the status:

systemctl status mtproxy

Step 8: Verification and Testing

Find out your public IP:

curl ifconfig.me

Connection link:

tg://proxy?server=YOUR_IP&port=443&secret=YOUR_SECRET

Open this link on your phone — Telegram will prompt you to add the proxy. A green indicator = the proxy is working.

Differences from the Docker Method

DockerFrom Source
Launch Speed5 minutes20–30 minutes
Updatedocker pullgit pull && make
IsolationBuilt into DockerRequires systemd + nobody user
FlexibilityLessFull control over the binary
TransparencyNeed to trust the imageYou compile from source yourself

FAQ

Which hosting provider is best? Hetzner and Contabo are the best value for money in Europe. DigitalOcean and Vultr are good alternatives with a wide geography.

Do I need a static IP? Yes. On most VPSs, it is static by default.

Can I run multiple MTProxies on one server? Yes, on different ports with different secrets.

How often should I update? Watch for tags at github.com/TelegramMessenger/MTProxy. Update once every 1–2 months or during critical security updates.


The next step after installation is optimization for high load and monetization via Promoted Channels.

Don't want to mess with a server? List of working proxies, updated every 60 seconds.