I'm using Traefik V3 and configure with Docker Swarm. I tried to access to https and let Traefik route to http service. It almost took 3 days but I can't get it work. Can someone point me out which was wrong?
Here my service config
version: '3'
networks:
app-extranet:
external: true
services:
app-web:
image: vue-app:development
deploy:
mode: replicated
replicas: 2
endpoint_mode: dnsrr
restart_policy:
condition: on-failure
delay: 2s
placement:
constraints:
- node.labels.frontend == true
labels:
- "traefik.enable=true"
- "traefik.http.services.fe-service.loadbalancer.server.scheme=http"
- "traefik.http.services.fe-service.loadbalancer.server.port=80"
- "traefik.http.routers.fe-route.entrypoints=websecure"
- "traefik.http.routers.fe-route.service=fe-service"
- "traefik.http.routers.fe-route.rule=PathPrefix(`/`)"
networks:
- app-extranet
logging:
driver: 'json-file'
options:
max-size: '200k'
max-file: '10'
and this is traefik config:
version: '3'
networks:
app-extranet:
external: true
services:
app-proxy:
image: traefik:v3.0
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- target: 80
published: 80
protocol: tcp
mode: host
- target: 443
published: 443
protocol: tcp
mode: host
- target: 8080
published: 8888
protocol: tcp
mode: host
deploy:
mode: replicated
replicas: 1
endpoint_mode: dnsrr
restart_policy:
condition: on-failure
delay: 2s
placement:
constraints:
- node.labels.proxy == true
command:
- --log.level=DEBUG
- --api.insecure=true
- --providers.swarm=true
- --providers.swarm.exposedByDefault=false
- --providers.swarm.network=app-extranet
- --providers.http.tls.insecureSkipVerify=true
- --entrypoints.traefik.address=:8080
- --entrypoints.web.address=:80
- --entrypoints.web.http.redirections.entryPoint.to=websecure
- --entrypoints.web.http.redirections.entryPoint.scheme=https
- --entrypoints.web.http.redirections.entryPoint.permanent=true
- --entrypoints.websecure.address=:443
networks:
- app-extranet
logging:
driver: 'json-file'
options:
max-size: '200k'
max-file: '10'
Additional information:
- I am using a local server, therefore I let Traefik auto generate certificate.
- It work perfect if i change front-end service route from
websecure
toweb
, the log show selected by WRR ... - It seem Traefik cannot route if
websecure
, here is part of log
proxy_mdo-proxy.1.o36v8d3jpdal@datacenter | 2024-07-02T09:08:21Z DBG github.com/traefik/traefik/v3/pkg/tls/tlsmanager.go:228 > Serving default certificate for request: ""
proxy_mdo-proxy.1.o36v8d3jpdal@datacenter | 2024-07-02T09:08:21Z DBG log/log.go:245 > http: TLS handshake error from 192.168.124.1:48576: remote error: tls: bad certificate
proxy_mdo-proxy.1.o36v8d3jpdal@datacenter | 2024-07-02T09:08:24Z DBG github.com/traefik/traefik/v3/pkg/tls/tlsmanager.go:228 > Serving default certificate for request: ""