Problema extraño de red: puertos 80 y 433 inaccesibles desde el exterior, Docker

Problema extraño de red: puertos 80 y 433 inaccesibles desde el exterior, Docker

Me estoy encontrando con un problema de red desconcertante que me tiene rascándome la cabeza. Esta es la situación: no puedo acceder a los puertos 80 y 433 desde el exterior, pero puedo reenviar cualquier otro puerto dentro de Docker, ¡y funciona perfectamente! Configuré UFW y también tengo K3 instalados, pero la mayor parte de mis servicios se ejecutan mediante Docker Compose.

Para investigar más a fondo, lancé un contenedor de prueba de Nginx y las cosas tomaron un giro aún más extraño.

Puedo acceder a este contenedor de prueba utilizando su IP interna de Docker, pero incluso un simple curl -I 127.0.0.1resultado genera un error 404:

-> # curl -I 127.0.0.1

HTTP/1.1 404 Not Found
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Wed, 20 Sep 2023 00:39:26 GMT
Content-Length: 19

La trama se complica cuando descubro que puedo acceder desde otra IP interna (una red VPN):

-> # curl -I 192.168.10.1

HTTP/1.1 200 OK
Server: nginx/1.25.2
Date: Wed, 20 Sep 2023 00:41:32 GMT
Content-Type: text/html
Content-Length: 615
Last-Modified: Tue, 15 Aug 2023 17:03:04 GMT
Connection: keep-alive
ETag: "64dbafc8-267"
Accept-Ranges: bytes

Pero aquí está el truco: cuando detengo el contenedor, es de esperar ver un error como este:

-> # curl -I 127.0.0.1

curl: (7) Failed to connect to 127.0.0.1 port 80 after 0 ms: Couldn't connect to server

Sin embargo, no, ¡me recibe el mismo error 404 persistente!


ACTUALIZAR:Para aumentar el misterio, cuando apago el contenedor Docker, intentar acceder 192.168.10.1también genera un error 404:

-> # curl -I 192.168.10.1

HTTP/1.1 404 Not Found
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Wed, 20 Sep 2023 00:51:49 GMT
Content-Length: 19

Estoy completamente desconcertado y no tengo idea de dónde se origina el problema. Para hacer las cosas aún más confusas, puedo repetir este experimento con el puerto 81 y todo funciona como se esperaba. Si alguien tiene alguna idea o sugerencia sobre cómo depurar esto, ¡apreciaría mucho su ayuda!


Aquí algunos resultados adicionales:

-> # lsof -i:80

COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
docker-pr 9815 root    4u  IPv4  54638      0t0  TCP *:http (LISTEN)
docker-pr 9823 root    4u  IPv6  48079      0t0  TCP *:http (LISTEN)
-> # docker ps

CONTAINER ID   IMAGE                 COMMAND                  CREATED          STATUS          PORTS                               NAMES
975e74d4bdfd   nginx:latest          "/docker-entrypoint.…"   29 minutes ago   Up 29 minutes   0.0.0.0:80->80/tcp, :::80->80/tcp   nginx_test_nginx-test_1
-> # ufw status

Status: active

To                         Action      From
--                         ------      ----
22/tcp                     ALLOW       Anywhere
80/tcp                     ALLOW       Anywhere
443                        ALLOW       Anywhere
Anywhere                   ALLOW       192.168.1.0/24
Anywhere                   ALLOW       192.168.178.0/24
81/tcp                     ALLOW       Anywhere
22/tcp (v6)                ALLOW       Anywhere (v6)
80/tcp (v6)                ALLOW       Anywhere (v6)
443 (v6)                   ALLOW       Anywhere (v6)
81/tcp (v6)                ALLOW       Anywhere (v6)


Anywhere on eth0           ALLOW FWD   Anywhere on wghub
Anywhere on wghub          ALLOW FWD   Anywhere on wghub
Anywhere (v6) on eth0      ALLOW FWD   Anywhere (v6) on wghub
Anywhere (v6) on wghub     ALLOW FWD   Anywhere (v6) on wghub
-> # netstat -ltnp

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name

tcp        0      0 127.0.0.1:10010         0.0.0.0:*               LISTEN      1374/containerd
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      631/sshd: /usr/sbin
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      9815/docker-proxy
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      610/systemd-resolve
tcp6       0      0 :::22                   :::*                    LISTEN      631/sshd: /usr/sbin
tcp6       0      0 :::80                   :::*                    LISTEN      9823/docker-proxy

-> # cat /etc/default/docker

DOCKER_OPTS="--iptables=false"

ACTUALIZAR:Esta es mi configuración de prueba:

docker-compose.yml

version: '3'

services:
  nginx-test:
    image: nginx:latest
    ports:
      - "80:80"

información relacionada