Hello!
I set up a docker compose with a traefik proxy, and a tomcat spring application, with websocket.
The ws working with a localhost tomcat, its working with the mapped ports, but nor working with the traefik:
the config:
reverse-proxy:
image: traefik:v2.10
container_name: "traefik"
command:
- "--log.level=DEBUG"
- "--accesslog=true"
- "--api.insecure=false"
- "--api.dashboard=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.websecure.address=:443"
- "--entryPoints.websecure.forwardedHeaders.insecure=false"
- "--entryPoints.websecure.proxyProtocol.insecure=false"
- "--entryPoints.websecure.forwardedHeaders.trustedIPs=10.0.0.0/8,172.16.0.0/16,192.168.0.0/16,fc00::/7"
- "--entryPoints.websecure.proxyProtocol.trustedIPs=10.0.0.0/8,172.16.0.0/16,192.168.0.0/16,fc00::/7"
- "--entrypoints.web.address=:80"
- "--certificatesresolvers.myresolver.acme.tlschallenge=true"
- "--certificatesresolvers.myresolver.acme.email=ignis.veneficus@gmail.com"
- "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik.rule=Host(`${TRAEFIK_HOST}`)"
- "traefik.http.routers.traefik.entrypoints=websecure"
- "traefik.http.routers.traefik.tls.certresolver=myresolver"
- "traefik.http.routers.traefik.service=api@internal"
- "traefik.http.middlewares.redirect.redirectscheme.scheme=https"
- "traefik.http.middlewares.redirect.redirectscheme.permanent=true"
- "traefik.http.middlewares.sslheader.headers.customrequestheaders.X-Forwarded-Proto=https"
- "traefik.wss.protocol=https"
ports:
- "80:80"
- "443:443"
volumes:
- ${ROOT_PATH}/letsencrypt:/letsencrypt
- /var/run/docker.sock:/var/run/docker.sock
restart: unless-stopped
for the webapp:
mud:
image: tomcat:9-jdk8-corretto
container_name: javamud
restart: unless-stopped
volumes:
- "${MUD_PATH}/data:/usr/local/tomcat/webapps"
- "${MUD_PATH}/conf:/usr/local/tomcat/conf"
labels:
- "traefik.enable=true"
- "traefik.http.routers.mud.entrypoints=websecure"
- "traefik.http.routers.mud.rule=Host(`${MUD_HOST}`)"
- "traefik.http.routers.mud.tls.certresolver=myresolver"
- "traefik.http.services.mud.loadbalancer.server.port=8080"
- "traefik.http.services.mud.loadbalancer.passHostHeader=true"
ports:
- "8092:8080"
The WSS closing by error 1006, the traefik log:
traefik | 192.168.xxx.xxx - - [18/Apr/2024:17:34:58 +0000] "GET /javaMud3/server HTTP/1.1" 403 0 "-" "-" 154 "mud@docker" "http://192.168.101.10:8080" 8ms
And its working if I connect to directy to the host via port 8092 (with http, and ws)
I think I miss one or more setting.
I did heavy googling but nothing helps.
Thanx
Csaba