Good morning,
I have a Traefik deployed over Docker from docker-compose file.
Traefik docker-compose.yml
version: '3'
services:
reverse-proxy:
image: traefik:v2.6
command:
- --api.dashboard=true
- --log.level=INFO
- --providers.docker
- --entrypoints.web.address=:80
- --entrypoints.websecure.address=:443
- --entrypoints.web.http.redirections.entryPoint.to=websecure
- --entrypoints.web.http.redirections.entryPoint.scheme=https
- --certificatesresolvers.letsencrypt.acme.email=xxx@xxx
- --certificatesresolvers.letsencrypt.acme.storage=acme.json
- --certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=web
- --certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- le_certs:/letsencrypt
labels:
- traefik.enable=true
- traefik.http.routers.api.entrypoints=websecure
- traefik.http.routers.api.rule=Host(`xxx.xxx.xxx`)
- traefik.http.routers.api.tls=true
- traefik.http.routers.api.tls.certresolver=letsencrypt
- traefik.http.routers.api.service=api@internal
- traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)
- traefik.http.routers.http-catchall.entrypoints=web
- traefik.http.routers.http-catchall.middlewares=redirect-to-https
- traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https
restart: always
volumes:
le_certs:
Web app docker-compose:
services:
nodejs:
image: nodejs
labels:
- traefi.enable=true
- traefik.http.routers.fap.rule=Host(`xxx.xxx.xxx`)
- traefik.http.routers.fap.entrypoints=websecure
- traefik.http.routers.fap.rule=hostregexp(`{host:.+}`)
- traefik.http.routers.fap.tls=true
- traefik.http.routers.fap.tls.certresolver=letsencrypt
I cannot access the web app. If I joiin into the Trafik dashboard, I got the Route, Services set up without any error, but you cannot join into the website because you get "Gateway timeout".
However, if you declare in Traefik docker-compose.yml:
version: '3'
networks:
default:
external:
name: external
services:
reverse-proxy:
image: traefik:v2.6
command:
- --api.dashboard=true
- --log.level=INFO
- --providers.docker
- --entrypoints.web.address=:80
- --entrypoints.websecure.address=:443
- --entrypoints.web.http.redirections.entryPoint.to=websecure
- --entrypoints.web.http.redirections.entryPoint.scheme=https
- --certificatesresolvers.letsencrypt.acme.email=xxx@xxx
- --certificatesresolvers.letsencrypt.acme.storage=acme.json
- --certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=web
- --certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- le_certs:/letsencrypt
labels:
- traefik.enable=true
- traefik.http.routers.api.entrypoints=websecure
- traefik.http.routers.api.rule=Host(`xxx.xxx.xxx`)
- traefik.http.routers.api.tls=true
- traefik.http.routers.api.tls.certresolver=letsencrypt
- traefik.http.routers.api.service=api@internal
- traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)
- traefik.http.routers.http-catchall.entrypoints=web
- traefik.http.routers.http-catchall.middlewares=redirect-to-https
- traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https
restart: always
volumes:
le_certs:
Web app docker-compose.yml
version: "3.9" # optional since v1.27.0
networks:
default:
external:
name: external
services:
nodejs:
image: nodejs
labels:
- traefi.enable=true
- traefik.http.routers.catalogo_pedrosa.rule=Host(`xxx.xxx.xx`)
- traefik.http.routers.catalogo_pedrosa.entrypoints=websecure
- traefik.http.routers.catalogo_pedrosa.rule=hostregexp(`{host:.+}`)
- traefik.http.routers.catalogo_pedrosa.tls=true
- traefik.http.routers.catalogo_pedrosa.tls.certresolver=letsencrypt
That works. What I am wrong?