Here are the steps to set up an MTProto proxy on a Raspberry Pi:
Prerequisites
- Raspberry Pi (any model will work)
- Raspbian OS or another compatible Linux distro installed
- Internet connection for the Pi
Steps
1. Install Docker
First, install Docker on your Raspberry Pi. You can follow the official Docker installation guide for Raspbian[1].
2. Run the MTProto Proxy Container
Once Docker is installed, run the following command to start the MTProto proxy container:
bash
docker run -d -v $PWD/config.toml:/config.toml -p 7104:7104 --name mtg-proxy --restart=unless-stopped nineseconds/mtg:2
This will:
- Run the container in detached mode (-d)
- Mount a local config file to the container (-v)
- Expose port 7104 on the host (-p)
- Name the container mtg-proxy
- Automatically restart the container unless manually stopped (--restart)
- Use the nineseconds/mtg:2 Docker image
3. Configure the Proxy
The proxy will use a default configuration, but you can customize it by creating a `config.toml` file in the same directory as the docker command and specifying options like the secret key, allowed IP ranges, etc.[2]
4. Forward the Port
Forward port 7104 on your Raspberry Pi to the outside world by configuring your router. This will allow clients to connect to your MTProto proxy[2].
5. Connect Clients
Provide the proxy server details (IP/hostname, port, secret) to Telegram clients that will use your MTProto proxy. They can then connect to Telegram through your proxy[2][3].
That's it! You now have an MTProto proxy running on your Raspberry Pi that can be used to access Telegram in restricted networks or countries. The Docker container makes it easy to set up and maintain.
Citations:[1] https://github.com/telegraf/telegraf/issues/507
[2] https://www.l1cafe.blog/2024/03/24/set-up-your-own-telegram-proxy.html
[3] https://github.com/HirbodBehnam/MTProtoProxyInstaller
[4] https://www.instructables.com/Setting-Up-Proxy-Server-in-Raspberry-Pi/
[5] https://www.instructables.com/Building-a-Simple-Proxy-Server-With-Raspberry-Pi/
[6] https://www.youtube.com/watch?v=Vi9jVR-PysA
[7] https://oastic.com/posts/how-to-install-your-own-telegram-proxy/
[8] https://forums.raspberrypi.com/viewtopic.php?t=85521