Skip to content

Proxy fails to connect to network when running inside a container #674

@fedinskiy

Description

@fedinskiy

I am trying to run MTProto proxy on a VPS. When I build the binary manually and run it on the baremetal, it works as expected. When I am running it inside a container on the same server, the clients fail to connect to it and the container becomes unresponsive.
The logs contain multiple instances of connect(): Network is unreachable, but curl inside the same container works just fine (see below). This happens both for official image[1] and for custom one[2].

[1] https://hub.docker.com/r/telegrammessenger/proxy/
[2] I build the image with the following Dockerfile:

FROM ubuntu:latest AS build

RUN apt update
RUN apt install -y git build-essential libssl-dev zlib1g-dev
RUN git clone https://github.com/TelegramMessenger/MTProxy
RUN cd MTProxy && make

FROM ubuntu:latest
RUN <<EOF
apt update
apt install -y curl xxd
mkdir /data
EOF
ENV PORT=8443
ENV HOST
COPY --from=build MTProxy/objs/bin/mtproto-proxy /mtproto-proxy
COPY <<"EOT" /start.sh
  #!/bin/bash
  set -eux
  INNER_HOST=$(hostname -I | tr " " "\n" | grep -P '\d+\.\d+\.\d+.\d+')
  curl -s https://core.telegram.org/getProxySecret -o /data/proxy-secret
  curl -s https://core.telegram.org/getProxyConfig -o /data/proxy-multi.conf
  if [[ ! -f /data/current_secret.txt ]]; then
   head -c 16 /dev/urandom | xxd -ps > /data/current_secret.txt
  fi
  ./mtproto-proxy -u nobody -H $PORT -S $( < data/current_secret.txt) --aes-pwd /data/proxy-secret /data/proxy-multi.conf -M 1 --nat-info $INNER_HOST:$HOST
EOT
RUN chmod u+x start.sh

CMD ["/bin/bash", "./start.sh"]

and start it like this:
podman run --rm --name=mtproto-proxy --cpus=0.3 -e EXTERNAL_HOST=$IP_ADDRESS_OMITTED -e PORT=8444 -p8444:8444 -v tlgrm:/data docker.io/fedinsky/mtproto

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions