• Docker
  • probleme entre NGINX proxy alpine et conteneur web

Bonjour à tous,

Je viens d'installer via Ansible Matrix grâce a un script tres bien et simple a programmer:
https://github.com/spantaleev/matrix-docker-ansible-deploy

jusque la tout fonctionne bien. chaque conteneur qui doit etre accessible depuis l'extérieur l'est grace au docker NGINX-Proxy installer par le script.

J'ai donc décidé d'ajouter a mon serveur des conteneur pour installer un système d'alias de mail :
https://github.com/simple-login/app

l'installation semble simple, installer quelques conteneurs en plus et ajouter une conf cotée NGINX-PROXY afin de profiter de l'application. J'ai simplement pas crée de nouveau network docker et ajouter chaque nouveau conteneur au réseau déjà existant. Durant l'installation tout ce passe bien je n'ai aucune erreur.

j'ai donc ajouté une conf a NGINX:

server {
      listen 8080;
      server_name app.mail.whita.org;
      server_tokens off;
      root /dev/null;
      location /.well-known/acme-challenge {
                                resolver 127.0.0.11 valid=5s;
                                set $backend "matrix-certbot:8080";
                                proxy_pass http://$backend;
                }
      location / {
        proxy_pass http://localhost:7777;
    }
    }

Malheureusement lorsque j'essaie d'accéder a mon URL je tombe sur le site par défaut mise en place lors de l'installation de MATRIX.

J'avoue que je ne sais plus trop ou regarder. pour information voici le docker lancé sur ma machine actuellement :

CONTAINER ID   IMAGE                                         COMMAND                  CREATED      STATUS                PORTS                                                                                                                                  NAMES
1eb4b6372136   simplelogin/app:3.4.0                         "python email_handle…"   5 days ago   Up 5 days             7777/tcp, 0.0.0.0:20381->20381/tcp                                                                                                     sl-email
4866bb73cfd4   simplelogin/app:3.4.0                         "gunicorn wsgi:app -…"   5 days ago   Up 5 days             0.0.0.0:7777->7777/tcp                                                                                                                 sl-app
6b5c172307ed   postgres:12.1                                 "docker-entrypoint.s…"   5 days ago   Up 5 days             0.0.0.0:5432->5432/tcp                                                                                                                 sl-db
6734eb19f2b3   turt2live/matrix-appservice-webhooks:latest   "docker-entrypoint.s…"   5 days ago   Up 5 days             9000/tcp                                                                                                                               matrix-appservice-webhooks
205c31313e8b   grafana/grafana:8.0.3                         "/run.sh"                5 days ago   Up 5 days             3000/tcp                                                                                                                               matrix-grafana
2ed30fdbee40   prom/prometheus:v2.28.0                       "/bin/prometheus --c…"   5 days ago   Up 5 days             9090/tcp                                                                                                                               matrix-prometheus
46dbb9f62036   prom/node-exporter:v1.1.2                     "/bin/node_exporter …"   5 days ago   Up 5 days             9100/tcp                                                                                                                               matrix-prometheus-node-exporter
ecfd8d1af078   dock.mau.dev/tulir/mautrix-whatsapp:latest    "/usr/bin/mautrix-wh…"   5 days ago   Up 5 days                                                                                                                                                    matrix-mautrix-whatsapp
76872876925d   dock.mau.dev/tulir/mautrix-facebook:latest    "python3 -m mautrix_…"   5 days ago   Up 5 days                                                                                                                                                    matrix-mautrix-facebook
56be9e5965de   nginx:1.21.0-alpine                           "/docker-entrypoint.…"   5 days ago   Up 5 days             80/tcp, 0.0.0.0:8448->8448/tcp, 0.0.0.0:80->8080/tcp, 0.0.0.0:443->8443/tcp                                                            matrix-nginx-proxy
b8312d3f7d18   coturn/coturn:4.5.2-r2-alpine                 "turnserver -c /turn…"   5 days ago   Up 5 days             0.0.0.0:3478->3478/tcp, 0.0.0.0:3478->3478/udp, 0.0.0.0:5349->5349/udp, 0.0.0.0:5349->5349/tcp, 0.0.0.0:49152-49172->49152-49172/udp   matrix-coturn
15f1cd98eee0   vectorim/element-web:v1.7.31                  "/docker-entrypoint.…"   5 days ago   Up 5 days             80/tcp                                                                                                                                 matrix-client-element
67259e58eb6a   matrixdotorg/synapse:v1.36.0                  "/start.py run -m sy…"   5 days ago   Up 5 days (healthy)   8008-8009/tcp, 8448/tcp                                                                                                                matrix-synapse
e5486a656647   ma1uta/ma1sd:2.4.0-amd64                      "/start.sh"              5 days ago   Up 5 days             8090/tcp                                                                                                                               matrix-ma1sd
710acf38144a   postgres:13.2-alpine                          "docker-entrypoint.s…"   5 days ago   Up 5 days             5432/tcp                                                                                                                               matrix-postgres
f73e18b3611a   devture/exim-relay:4.94.2-r0-2                "/sbin/tini -- exim …"   5 days ago   Up 5 days             8025/tcp                                                                                                                               matrix-mailer

Merci par avance si vous avez des idées pour m'aider à avancer dans ce problème. N'hésitez pas si vous avez besoin d'autre information.

BBO

  • Je me réponds a moi même:

    J'ai pas les connaissance sur docker mais en gros ajouter les docker au réseaux comme jel'ai fait n'induit pas que nginx connaisse local host. il faut plutot utiliser nom-du-docker:7777.

    Voici la réponse faite par les personne gérant le git d'installation de mon matrix:

    f you're running some other service in the matrix Docker network, you need to use the name of the container, not localhost. Example: proxy_pass http://my-container-name:7777.
    
    Make sure your container has a static name by starting it with docker run --name=my-container-name.
    
    By the way, such proxy_pass http://my-container-name:7777 directives are DNS-resolved at nginx start time, so your my-container-name container needs to be up and running at the time nginx (matrix-nginx-proxy) starts. If you restart the container later, its IP may change and it may break.
    
    A better way to do it is to do a hack like this:
    
    12345location / {
        resolver 127.0.0.11 valid=5s;
        set $backend "my-container-name:7777";
        proxy_pass http://$backend;
    }
    
    ^^ This makes nginx DNS-resolve my-container-name once every 5 seconds via Docker's internal DNS server (127.0.0.11). This way, it doesn't matter exactly when your container gets started or restarted.```
BBO a renommé le titre en probleme entre NGINX proxy alpine et conteneur web.

Je me réponds a moi même:

J'ai pas les connaissance sur docker mais en gros ajouter les docker au réseaux comme jel'ai fait n'induit pas que nginx connaisse local host. il faut plutot utiliser nom-du-docker:7777.

Voici la réponse faite par les personne gérant le git d'installation de mon matrix:

f you're running some other service in the matrix Docker network, you need to use the name of the container, not localhost. Example: proxy_pass http://my-container-name:7777.

Make sure your container has a static name by starting it with docker run --name=my-container-name.

By the way, such proxy_pass http://my-container-name:7777 directives are DNS-resolved at nginx start time, so your my-container-name container needs to be up and running at the time nginx (matrix-nginx-proxy) starts. If you restart the container later, its IP may change and it may break.

A better way to do it is to do a hack like this:

12345location / {
    resolver 127.0.0.11 valid=5s;
    set $backend "my-container-name:7777";
    proxy_pass http://$backend;
}

^^ This makes nginx DNS-resolve my-container-name once every 5 seconds via Docker's internal DNS server (127.0.0.11). This way, it doesn't matter exactly when your container gets started or restarted.```
BBO a renommé le titre en [RESOLUE] probleme entre NGINX proxy alpine et conteneur web.
hydrog3n a renommé le titre en probleme entre NGINX proxy alpine et conteneur web.
Répondre…