I'm struggling to get the headers middleware to work with a websocket connection, am I doing something wrong or is this not supported? Minimal example docker compose below.
version: "3.3"
services:
traefik:
image: "traefik:v2.7"
container_name: "traefik"
command:
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
ports:
- "80:80"
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
labels:
- "traefik.enable=true"
- "traefik.http.middlewares.chickenheader.headers.customresponseheaders.chicken=tasty"
whoami:
image: "traefik/whoami"
container_name: "simple-service"
labels:
- "traefik.enable=true"
- "traefik.http.routers.whoami.rule=Host(`whoami.localhost`)"
- "traefik.http.routers.whoami.entrypoints=web"
- "traefik.http.routers.whoami.middlewares=chickenheader"
websocket:
image: elegantmonkeys/websockets-demo
labels:
- "traefik.enable=true"
- "traefik.http.routers.websocket.rule=Host(`websocket.localhost`)"
- "traefik.http.routers.websocket.entrypoints=web"
- "traefik.http.routers.websocket.middlewares=chickenheader"
The header is set correctly for the whoami service:
HTTP/1.1 200 OK
Chicken: tasty
Content-Length: 815
Content-Type: text/plain; charset=utf-8
Date: Wed, 13 Jul 2022 10:10:21 GMT
But not for the websocket:
HTTP/1.1 101 Switching Protocols
Connection: Upgrade
Sec-Websocket-Accept: fh6cm5211R7WI6cIK8h50Cqfuew=
Sec-Websocket-Extensions: permessage-deflate
Upgrade: websocket
Many thanks.