MTProto Proxy Erlang Docker Tutorial and Troubleshooting Tips

Author

Reads 930

Programming Language on a Screen
Credit: pexels.com, Programming Language on a Screen

Getting started with an MTProto proxy in Erlang using Docker can be a bit overwhelming, especially for beginners. You'll need to have Erlang installed on your system first.

In this tutorial, we'll cover the basic steps to set up an MTProto proxy in Erlang using Docker. We'll also provide some troubleshooting tips to help you overcome common issues.

To start, you'll need to pull the official MTProto proxy Docker image from the Docker Hub repository. You can do this by running the command `docker pull mtproto-proxy/mtproto-proxy:latest` in your terminal.

Make sure you have Docker installed and running on your system before proceeding.

What is MTProxy?

MTProxy is a proxy server that uses the MTProto protocol of Telegram to provide a safe and stable way for users to access Telegram.

It's built from the official Telegram source code, making it a reliable solution. MTProxy is available as a Docker image, with the name mtproxy/mtproxy being an unofficial version.

This Docker image makes it easy to deploy a proxy without complicated configurations.

Setup and Configuration

Photography Setup of Organic Hygiene Products
Credit: pexels.com, Photography Setup of Organic Hygiene Products

To set up an MTProto proxy, you'll need to run a Docker container. You can do this by running the following command:

docker run -d -p 443:443 --name=mtproto-proxy --restart=always -v proxy-config:/data telegrammessenger/proxy:latest

This command creates a container named "mtproto-proxy" that maps port 443 on your machine to port 443 in the container, and mounts a volume at /data inside the container.

The container will automatically generate a secret and display it in the log, along with other important information such as the tg:// link for auto-configuration, the t.me link for sharing the proxy, and the external IP address of your machine.

Here are the key pieces of information you'll find in the log:

  • Secret: the generated secret for configuring the proxy
  • tg:// link: the link to auto-configure the proxy in Telegram
  • t.me link: the link to share the proxy via Telegram
  • External IP: the public IP address of your machine

You can copy and paste the tg:// link or t.me link into your Telegram app to configure the proxy.

Note that if you've changed the port from the default 443, you'll need to modify the tg:// link or t.me link accordingly. For example, if you've changed the port to 678, the link would be: tg://proxy?server=1.2.3.4&port=678&secret=…..

Tips and Troubleshooting

Credit: youtube.com, Configure HTTP proxy in docker service | add server proxy in docker containers | proxy configuration

If you're experiencing issues with your mtproto proxy Erlang Docker setup, check the logs for any errors related to the proxy configuration. Make sure the PROXY_PORT and PROXY_IP variables are set correctly.

If you're getting a "connection timed out" error, try increasing the timeout value in the proxy configuration. This can be done by setting the PROXY_TIMEOUT variable to a higher value.

For common issues like proxy not starting or mtproto not connecting, refer to the troubleshooting section in the original article for more detailed solutions.

Mẹo Sử Dụng

When using a container for Telegram, it's essential to know how to store and manage it properly.

Secrets are stored in the /data volume, which remains unchanged even after container upgrades.

To change the default port, you can use the -p flag, but make sure to update any tg:// or t.me links to match the new port.

Regularly restarting the container is recommended to update the Telegram core servers' IP list. You can set up a cron job to automate this process.

Client Stuck in "Updating" State

Close Up Photo of Programming of Codes
Credit: pexels.com, Close Up Photo of Programming of Codes

If your client is stuck in the "Updating" state, it's likely due to a firewall issue between the proxy and Telegram core servers.

Check your firewall settings to ensure they're not blocking the connection.

A time synchronization issue might also be the culprit, so make sure your system's time is set correctly and synchronized with UTC within a 5-second margin. You can use ntp or chrony to achieve this.

If your proxy is behind a NAT, you'll need to specify the IP and INTERNAL_IP in your environment variables.

Monitoring and Management

Monitoring and Management is a crucial aspect of running a successful mtproto proxy erlang docker setup. To keep an eye on things, you can access the stats endpoint at http://localhost:2398/stats.

The stats endpoint provides valuable information about your setup. You can see the number of Telegram core servers your proxy will connect to, which is displayed as ready_targets.

The active_targets field shows the actual number of servers your proxy has connected to. This is an important metric to keep an eye on, as it can help you identify any issues with your setup.

Man in Black Hoodie Sitting on Chair Looking at Computer Monitor
Credit: pexels.com, Man in Black Hoodie Sitting on Chair Looking at Computer Monitor

You can also see the total number of client connections, which is displayed as total_special_connections. This can help you gauge the load on your setup and make adjustments as needed.

The total_max_special_connections field shows the maximum number of connections allowed, which is calculated as 60,000 times the number of worker processes.

Here's a summary of the stats you can access through the endpoint:

  • ready_targets: Number of Telegram core servers your proxy will connect to
  • active_targets: Actual number of servers your proxy has connected to
  • total_special_connections: Total number of client connections
  • total_max_special_connections: Maximum number of connections allowed (60,000 × number of worker processes)

Definitions and Variables

Let's break down the variables that are crucial for our mtproto proxy Erlang Docker setup.

ready_targets refers to the number of Telegram servers that are ready to handle proxy requests.

active_targets is the number of Telegram servers that are currently handling proxy requests.

For our proxy to function effectively, we need to keep track of the total number of incoming connections, which is represented by total_special_connections.

There's also a limit to the number of incoming connections, and that's what total_max_special_connections is all about.

Here's a quick rundown of the key variables we're working with:

Conclusion

Credit: youtube.com, Docker Proxy Settings - Docker Development Tips & Tricks

In the world of mtproto proxy Erlang Docker, being part of the "Digital Resistance" is a badge of honor, providing a reliable communication channel to those who need it.

We've established a solid foundation with MtprotoProxyTelegram and OpenVPN deployed on the server, resulting in no delays or pings.

With a ping of ~100-250ms, voice communication is seamless, a testament to the power of a well-configured setup.

The best part? Financial costs for this entire operation are zero rubles, a significant advantage for those on a budget.

Here's a quick rundown of the benefits:

  • No delays or pings with MtprotoProxyTelegram and OpenVPN deployed
  • Seamless voice communication with a ping of ~100-250ms
  • Financial costs = 0₽

Tiffany Kozey

Junior Writer

Tiffany Kozey is a versatile writer with a passion for exploring the intersection of technology and everyday life. With a keen eye for detail and a knack for simplifying complex concepts, she has established herself as a go-to expert on topics like Microsoft Cloud Syncing. Her articles have been widely read and appreciated for their clarity, insight, and practical advice.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.