Home Arrow Icon Knowledge base Arrow Icon Global Arrow Icon How do I configure a custom secret for the MTProxy Docker container


How do I configure a custom secret for the MTProxy Docker container


To configure a custom secret for the MTProxy Docker container, you can use the following methods:

Using Environment Variables

1. Create a `.env` file in the same directory as your `docker-compose.yml` file with the following content:


SECRET=your_custom_secret_here

Replace `your_custom_secret_here` with your desired secret.

2. In your `docker-compose.yml` file, reference the `SECRET` environment variable in the `environment` section of the MTProxy service:

yaml
services:
  mtproxy:
    image: mtproxy/mtproxy
    environment:
      - SECRET=${SECRET}

3. Start the container using `docker-compose up -d`.

Using a Secrets File

1. Create a file named `secret.txt` (or any name you prefer) with your custom secret:


your_custom_secret_here

2. In your `docker-compose.yml` file, mount the `secret.txt` file as a secret in the MTProxy service:

yaml
services:
  mtproxy:
    image: mtproxy/mtproxy
    secrets:
      - source: mtproxy_secret
        target: /data/secret
secrets:
  mtproxy_secret:
    file: secret.txt

3. Start the container using `docker-compose up -d`.

Using the `docker run` Command

If you're not using Docker Compose, you can specify the custom secret when running the container:

bash
docker run -d -p443 --name=mtproxy --restart=always -v /etc/mtproxy:/data -e SECRET=your_custom_secret_here mtproxy/mtproxy

Replace `your_custom_secret_here` with your desired secret.

In all cases, the secret will persist across container upgrades in a volume. It is a mandatory configuration parameter, and if not provided, it will be generated automatically at container start[1][5].

Citations:
[1] https://git.esin.io/github/across/commit/11440fab176db73640c4ea3b87cb0b6a9390314f?style=unified&whitespace=ignore-all
[2] https://github.com/Dofamin/MTProxy-Docker
[3] https://github.com/iShift/docker-compose-mtproxy
[4] https://docs.docker.com/build/building/secrets/
[5] https://hub.docker.com/r/mtproxy/mtproxy
[6] https://hub.docker.com/r/seriyps/mtproto-proxy
[7] https://codesandbox.io/s/telegrammessenger-mtproxy-yuui8f
[8] https://crates.io/crates/mtproxy