Home What Is a Proxy Server? How to Deploy an MTProto Proxy on a CentOS Server?

How to Deploy an MTProto Proxy on a CentOS Server?

user profile
Pandada 文章于 2024-06-10 发布
0

MTProto Proxy for Telegram is a popular solution for fast and secure messaging. If you need to deploy an MTProto proxy on your CentOS server to enhance security and circumvent network restrictions, here is a detailed Telegram Proxy guide that will lead you through installing the necessary software to configuring and running your MTProto proxy server.

How to Deploy MTProto Proxy

Deploying an MTProto Proxy on a CentOS server involves several steps, using the official MTProxy. Follow these steps:

1. Update System and Install Necessary Packages

Open your CentOS server terminal, ensure all system software is up-to-date, then install dependencies required to compile MTProxy:

sudo yum update
sudo yum install git curl make gcc openssl-devel zlib-devel

2. Download and Compile MTProxy

Clone MTProxy source code from GitHub and compile it:

cd /opt
sudo git clone https://github.com/TelegramMessenger/MTProxy
cd MTProxy
sudo make && cd objs/bin

3. Generate Secret Key

MTProxy requires a key to operate, generate one using:

curl -s https://core.telegram.org/getProxySecret -o proxy-secret
curl -s https://core.telegram.org/getProxyConfig -o proxy-multi.conf
head -c 16 /dev/urandom | xxd -ps

Record the outputted 16-byte key, which will be used later.

4. Start MTProxy

Start the proxy server using the previously generated key:

 ./mtproto-proxy -u nobody -p 8888 -H 443 -S <插入你的密钥> --aes-pwd proxy-secret proxy-multi.conf -M 1

The `-p 8888` is the internal service port, `-H 443` is the client connection port, `-S <插入你的密钥>` should be replaced with your generated key. `-M 1` denotes the maximum number of workers.

5. Configure Firewall Rules

Ensure your server's firewall allows client connections to the MTProxy port (e.g., 443):

sudo firewall-cmd --zone=public --add-port=443/tcp --permanent
sudo firewall-cmd --reload

6. Set as System Service (Optional)

To ensure MTProxy automatically starts after server reboot, create a system service:

Create a file named `/etc/systemd/system/mtproxy.service` with the following content:

[Unit]
Description=MTProxy
After=network.target

[Service]
Type=simple
WorkingDirectory=/opt/MTProxy/objs/bin
ExecStart=/opt/MTProxy/objs/bin/mtproto-proxy -u nobody -p 8888 -H 443 -S <插入你的密钥> --aes-pwd proxy-secret proxy-multi.conf -M 1
Restart=on-failure

[Install]
WantedBy=multi-user.target

Then enable and start the service:

sudo systemctl enable mtproxy.service
sudo systemctl start mtproxy.service

7. Verify MTProxy is Running

Check if MTProxy port is listening properly using `netstat` or `ss` commands:

sudo ss -tulpn | grep 443

Follow these steps, and you should successfully deploy an MTProto proxy on your CentOS server.

How to Use MTProto Proxy

The main purpose of using an MTProto proxy is to provide secure and private messaging through the Telegram app. Users can configure the proxy in Telegram settings to connect via the proxy server, enhancing privacy protection and bypassing regional restrictions.

How to configure MTProto proxy in Telegram:

1. Open the Telegram app: Launch Telegram on your mobile or desktop.

2. Go to Settings: Click on the "Settings" menu.

3. Select Data and Storage: Find and select "Data and Storage" from the settings list.

4. Configure Proxy: Scroll down to "Proxy Settings" and click "Proxy" (or "Add Proxy" in some versions).

5. Add New Proxy: Choose "Add Proxy" and then select "MTProto".

6. Enter Proxy Details:

   - Server: Enter the IP address or domain name of your server.

   - Port: Enter the port your MTProxy is listening on, usually 443.

   - Secret Key: Enter the 16-byte key you previously generated.

7. Save and Connect: After entering the details, save the settings and enable the proxy server.

Once configured, Telegram will attempt to connect via your configured MTProto proxy. If everything is set up correctly, you should be able to use Telegram normally through the proxy, enjoying a more secure communication environment.

The final proxy format output in Telegram typically appears in this format:

tg://proxy?server=YOUR_SERVER_IP&port=443&secret=YOUR_SECRET_KEY

This is a URL format that includes your server IP address (`YOUR_SERVER_IP`), port (usually `443`), and the secret key (`YOUR_SECRET_KEY`) generated during the MTProto proxy setup. Users can directly click such a link (if shared via a web page or chat software) to quickly configure the Telegram proxy settings.

Summary

By following the steps above, you should now have successfully set up and run an MTProto proxy on your CentOS server. This provides a secure, fast proxy service for Telegram users, helping to protect their communications from eavesdropping. Remember to regularly check and update your MTProxy software and server operating system to ensure all security patches are applied. Additionally, it's advisable to continuously monitor server performance and any security alerts to maintain optimal service conditions. This not only ensures the stable operation of your proxy but also ensures the data security and access quality for end-users.

How to Deploy an MTProto Proxy on a CentOS Server? review FAQ

You can find your server's IP address by running the `ip addr` command in your server terminal. This will list all network interfaces and their IP addresses. Typically, you should use the IP address associated with the interface connected to the external network.

You can check if port 443 is being listened to by the MTProto proxy process by using the command `sudo ss -tulpn | grep 443`. If the output shows the MTProto proxy process, it is running. Also, ensure your firewall settings allow external access to this port.

First, confirm that the server address, port, and secret key you entered are correct. Secondly, check if your server's firewall settings permit external devices to connect to your proxy port (default is 443). Lastly, ensure that your network connection is not restricted or blocked, which could affect the use of the proxy.
Previous article Bulk Facebook Account Registration and Login with Static Proxies Managing multiple Facebook acc...
Next article Understanding Static Residential Proxies and ISP Proxies Static residential proxies and...
blog
How to Deploy an MTP...

MTProto Proxy for Telegram is ...

Please contact us directly via email [email protected]

Recommended merchants