Skip to content

v2: chain middleware removes headers added by headers middleware #5890

@JamesKyburz

Description

@JamesKyburz

Do you want to request a feature or report a bug?

Bug

What did you do?

Expect to see custom headers when the headers middleware is used.

What did you expect to see?

custom headers

What did you see instead?

When the chain middleware is used custom headers are not present in the response.

Output of traefik version: (What version of Traefik are you using?)

v2.1

(paste your output here)

What is your environment & configuration (arguments, toml, provider, platform, ...)?

# (paste your configuration here)

Using chain the custom headers are not present.

Example docker-compose-bug.yml

~/Documents/src/traefik-bug/root1 ᐅ cat docker-compose-bug.yml

version: '3'
services:
  reverse-proxy:
    image: traefik:v2.1
    networks:
      - traefik-bug-root1
    command:
      - '--providers.docker'
    ports:
    - 8095:80
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
    restart: always

  test:
    networks:
    - traefik-bug-root1
    image: hashicorp/http-echo
    command: "-listen :5000 -text='hi'"
    labels:
    - 'traefik.enable=true'
    - 'traefik.http.routers.test.rule=PathPrefix(`/test`)'
    - 'traefik.http.routers.test.middlewares=test'
    - 'traefik.http.services.test.loadbalancer.server.port=5000'
    - 'traefik.http.middlewares.test.chain.middlewares=test-headers,test-compress'
    - 'traefik.http.middlewares.test-compress.compress=true'
    - 'traefik.http.middlewares.test-headers.headers.customresponseheaders.X-Custom-Response-Header=value'

networks:
  traefik-bug-root1:
    driver: bridge

If the chain middleware is not used custom headers are present.

~/Documents/src/traefik-bug/root1 ᐅ cat docker-compose-ok.yml

version: '3'
services:
  reverse-proxy:
    image: traefik:v2.1
    networks:
      - traefik-bug-root1
    command:
      - '--providers.docker'
    ports:
    - 8095:80
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
    restart: always

  test:
    networks:
    - traefik-bug-root1
    image: hashicorp/http-echo
    command: "-listen :5000 -text='hi'"
    labels:
    - 'traefik.enable=true'
    - 'traefik.http.routers.test.rule=PathPrefix(`/test`)'
    - 'traefik.http.routers.test.middlewares=test-headers'
    - 'traefik.http.services.test.loadbalancer.server.port=5000'
    - 'traefik.http.middlewares.test-headers.headers.customresponseheaders.X-Custom-Response-Header=value'

networks:
  traefik-bug-root1:
    driver: bridge

If applicable, please paste the log output in DEBUG level (--log.level=DEBUG switch)

(paste your output here)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions