A secure and efficient MTProto proxy implementation for Telegram using the mtg (Go-based) proxy server.
- 🚀 High-performance Go implementation
- 🔒 Secure MTProto protocol support
- 🐳 Docker support for easy deployment
- 🔧 Simple configuration via environment variables
- 📊 Built-in monitoring and statistics
- 🛡️ Security best practices implemented
- 🌐 Support for multiple users
- 📱 Compatible with all Telegram clients
- Docker and Docker Compose (recommended)
- OR Go 1.19+ (for manual installation)
- Linux/macOS/Windows with WSL2
- Clone and setup:
git clone <your-repo>
cd mtproto-proxy
cp .env.example .env- Edit
.envfile with your configuration:
nano .env- Start the proxy:
docker-compose up -d- Check logs:
docker-compose logs -f- Run the installation script:
chmod +x install.sh
./install.sh- Configure environment:
cp .env.example .env
nano .env- Start the proxy:
./start.shAll configuration is done via environment variables in the .env file:
MTG_SECRET: Proxy secret key (auto-generated if not set)MTG_PORT: Port to listen on (default: 8443)MTG_BIND_IP: IP address to bind to (default: 0.0.0.0)
MTG_DOMAIN: Domain for TLS camouflageMTG_WORKERS: Number of worker processesMTG_BUFFER_SIZE: Buffer size for connectionsMTG_ANTI_REPLAY_MAX_SIZE: Anti-replay protection sizeMTG_STATS_IP: IP for statistics endpointMTG_STATS_PORT: Port for statistics endpoint
MTG_SECURE_ONLY: Enable secure mode onlyMTG_DISABLE_IPV6: Disable IPv6 supportMTG_TIMEOUT: Connection timeout
After starting the proxy, you'll get a connection link in the format:
https://t.me/proxy?server=YOUR_SERVER&port=YOUR_PORT&secret=YOUR_SECRET
- Open the proxy link in your browser
- Telegram will open and ask to add the proxy
- Confirm to start using the proxy
Access statistics at: http://YOUR_SERVER:STATS_PORT/stats
- Use Strong Secrets: Always generate strong, random secrets
- Firewall Configuration: Only expose necessary ports
- Regular Updates: Keep the proxy software updated
- Monitor Usage: Regularly check proxy statistics
- Use TLS: Enable TLS camouflage when possible
- Limit Access: Consider IP whitelisting for admin access
-
Port Already in Use:
sudo netstat -tulpn | grep :8443 sudo kill -9 <PID>
-
Permission Denied:
sudo chown -R $USER:$USER . chmod +x *.sh
-
Connection Refused:
- Check firewall settings
- Verify port configuration
- Check if service is running
- Docker:
docker-compose logs -f - Manual: Check
logs/mtg.log
For high-traffic scenarios:
- Increase worker count:
MTG_WORKERS=4 - Adjust buffer size:
MTG_BUFFER_SIZE=65536 - Use dedicated server with SSD storage
- Configure proper firewall rules
- Monitor system resources
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
This proxy is intended for legitimate use cases where Telegram access is restricted. Please comply with local laws and regulations.
For issues and questions:
- Check the troubleshooting section
- Review logs for error messages
- Open an issue on GitHub
Note: This implementation uses the mtg proxy server, which is a third-party implementation of the MTProto protocol. It is not officially endorsed by Telegram.