sudo apt install git curl build-essential libssl-dev zlib1g-dev -y
git clone https://github.com/TelegramMessenger/MTProxy \
  && cd MTProxy \
  && make \
  && cd objs/bin \
  && curl -s https://core.telegram.org/getProxySecret -o proxy-secret \
  && curl -s https://core.telegram.org/getProxyConfig -o proxy-multi.conf

Generate a secret to be used by users to connect to your proxy:

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

Run in foreground:

./mtproto-proxy -u nobody -p 8888 -H 6443 -S  --aes-pwd proxy-secret proxy-multi.conf -M 1

Run as a service:

Create file /etc/systemd/system/MTProxy.service:

[Unit]
Description=MTProxy
After=network.target

[Service]
Type=simple
WorkingDirectory=/opt/MTProxy
ExecStart=/opt/MTProxy/mtproto-proxy -u nobody -p 8888 -H 6443 -S  -aes-pwd /opt/MTProxy/proxy-secret /opt/MTProxy/proxy-multi.conf -M 1
Restart=on-failure

[Install]
WantedBy=multi-user.target

/opt/MTProxy is your MTProxy file directory.

systemctl daemon-reload \
  && systemctl start MTProxy.service \
  && systemctl enable MTProxy.service

Check the status:

systemctl status MTProxy.service

Github - TelegramMessenger/MTProxy