Home Arrow Icon Knowledge base Arrow Icon Global Arrow Icon How do I configure V2Ray for MTProto proxy


How do I configure V2Ray for MTProto proxy


Configuring V2Ray for MTProto Proxy

To configure V2Ray for an MTProto proxy, you need to set up both an inbound and outbound proxy. Here's how to do it:

Inbound Configuration

1. In your V2Ray configuration file, add an inbound proxy with the `mtproto` protocol:

json
"inbounds": [
  {
    "port": 443,
    "protocol": "mtproto",
    "settings": {
      "users": [
        {
          "secret": "b0cbcef5a486d9636472ac27f8e11a9d"
        }
      ]
    }
  }
]

2. The `secret` should be a 32-character string containing only hexadecimal digits (0-9, a-f). You can generate one using:

bash
openssl rand -hex 16

3. Save the configuration file and restart V2Ray.

Outbound Configuration

1. Add an outbound proxy with the `mtproto` protocol:

json
"outbounds": [
  {
    "protocol": "mtproto",
    "settings": {}
  }
]

2. Save the configuration file and restart V2Ray.

Routing Configuration

To route Telegram traffic through the MTProto proxy, add a routing rule:

json
"routing": {
  "rules": [
    {
      "type": "field",
      "domain": [
        "geosite:telegram"
      ],
      "outboundTag": "proxy"
    }
  ]
}

This will route all Telegram traffic to the `proxy` outbound, which should be the MTProto outbound you configured earlier.

Configuring Telegram

1. In Telegram, go to Settings > Advanced > Connection Type and select "Use MTProto proxy".

2. Enter the following details:
- Server: Your domain or IP address
- Port: 443
- Secret: The secret you generated earlier

3. Click "Connect" and Telegram will use the MTProto proxy.

That's it! With this configuration, V2Ray will act as an MTProto proxy for Telegram traffic. The inbound proxy listens on port 443 and the outbound proxy sends traffic to Telegram's servers using the MTProto protocol[1].

Citations:
[1] https://www.v2ray.com/en/configuration/protocols/mtproto.html
[2] https://www.youtube.com/watch?v=QKDmeLrjApc
[3] https://gist.github.com/ihciah/7bafb480fb0b09db02c5c86c5b689819
[4] https://www.columbia.edu/~bm2734/blog/v2ray-brook/
[5] https://v2how.github.io/post/2021-02-18-camouflage-telegram-mtproto-proxy-ubuntu-20-04/
[6] https://cloudzy.com/blog/what-is-v2ray-vpn/
[7] https://gist.github.com/hirakujira/f4d4acd1c0e4a0d2e478336035b50b15
[8] https://www.v2ray.com/ko/configuration/protocols/mtproto.html