Hello,
I try to configure an api using docker and traefik on my vps server.
When I try to connect to the whoami service I get an connexion refused
Here is my traefik config file
entryPoints:
web:
address: ":80"
web-secure:
address: ":443"
certificatesResolvers:
letsencrypt:
acme:
email: myadress@gmail.com
storage: /certs/acme.json
httpChallenge:
entryPoint: web
http:
middlewares:
redirect-to-https:
redirectScheme:
scheme: https
permanent: true
Here is my docker config:
services:
traefik:
image: traefik:latest
container_name: traefik
restart: unless-stopped
security_opt:
- no-new-privileges:true
environment:
- TZ=Europe/Brussels # Change this to your timezone
networks:
- traefik-proxy
ports:
- 80:80 # HTTP entryPoints
- 443:443 # HTTPS entryPoints
- 8080:8080 # Dashbaord WebGui
volumes:
- ./traefik.yml:/traefik.yml:ro
- letsencrypt:/certs
command:
- --api.dashboard=true
- --log.level=INFO
- --api.insecure=true
- --providers.docker
#- --log.filepath=/var/log/traefik.log
- --accesslog=true
#- --accesslog.filepath=/var/log/traefik-access.log
- --providers.docker.network=traefik-proxy
- --providers.docker.exposedByDefault=false
- --entrypoints.web.address=:80
- --entrypoints.web.http.redirections.entrypoint.to=web-secure
- --entryPoints.web.http.redirections.entrypoint.scheme=https
- --entrypoints.websecure.address=:443
# remove next line when using Traefik v2
- --entrypoints.websecure.asDefault=true
- --entrypoints.websecure.http.tls.certresolver=letsencrypt
- --certificatesresolvers.letsencrypt.acme.email=mail@example.com
- --certificatesresolvers.letsencrypt.acme.tlschallenge=true
- --certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json
labels:
- traefik.enable=true
- traefik.http.routers.mydashboard.rule=Host(`traefik.srv.mydomain.be`)
- traefik.http.routers.mydashboard.service=api@internal
- traefik.http.routers.mydashboard.middlewares=myauth
- traefik.http.middlewares.myauth.basicauth.users=test:test
whoami:
image: traefik/whoami:latest
container_name: whoami
ports:
- '8083:8083'
networks:
- traefik-proxy # or your frontend network
labels:
- traefik.enable=true
- traefik.http.routers.whoami.rule=Host(`whoami.srv.mydomain.be`)
- traefik.http.routers.whoami.entrypoints=web-secure
- traefik.http.routers.whoami.tls.certresolver=letsencrypt
- traefik.http.middlewares.mywwwredirect.redirectregex.regex=^https://www\.(.*)
- traefik.http.middlewares.mywwwredirect.redirectregex.replacement=https://$${1}
- traefik.http.routers.mywhoami.middlewares=mywwwredirect
networks:
traefik-proxy:
external: true
backend:
volumes:
letsencrypt:
I'm a noob with traefik and letsencrypt so be indulgent please