Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom headers are not applied with docker #2832

Closed
talolard opened this issue Feb 9, 2018 · 2 comments
Closed

Custom headers are not applied with docker #2832

talolard opened this issue Feb 9, 2018 · 2 comments

Comments

@talolard
Copy link

talolard commented Feb 9, 2018

Related to #2028 #2030

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

Bug

What did you do?

I'm using Traefik v1.51 on docker swarm mode.
I launch it as a service with the following command

docker service create \
    --name traefik \
    --constraint=node.role==manager \
    --publish 80:80 --publish 8080:8080 --publish 443:80\
    --mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock \
    --network traefik-net \
    --label com.docker.aws.lb.arn="arn:aws:acm:us-east-1:052831428797:certificate/ef25f821-f311-4b29-99e7-099ab624aa99" \
    traefik \
    --docker \
    --docker.swarmmode \
    --docker.domain=traefik \
    --docker.watch \
    --web

I launch a stack with the following compose file

version: '3'

services:
    frontend:
        image: my_image
        networks:
            - traefik-net
        deploy:
            labels:
                 - "traefik.port=5000"
                 - "traefik.docker.network=traefik-net"
                 - "traefik.frontend.rule=Host:test.lighttag.io"
                 - "traefik.frontend.headers.customresponseheaders=X-Testing-1:544"
networks:
    traefik-net:
        external: true

What did you expect to see?

When I do
curl -i -v http://nlph.lighttag.io
I expect the header X-Testing-1:544 to be returned

What did you see instead?

curl -i -v   http://test.lighttag.io 
* Rebuilt URL to: http://test.lighttag.io/
*   Trying my_ip ...
* Connected to test.lighttag.io (my_ip) port 80 (#0)
> GET / HTTP/1.1
> Host: test.lighttag.io
> User-Agent: curl/7.47.0
> Accept: */*
> 
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Accept-Ranges: bytes
Accept-Ranges: bytes
< Cache-Control: public, max-age=0
Cache-Control: public, max-age=0
< Content-Length: 724
Content-Length: 724
< Content-Type: text/html; charset=utf-8
Content-Type: text/html; charset=utf-8
< Date: Fri, 09 Feb 2018 14:45:40 GMT
Date: Fri, 09 Feb 2018 14:45:40 GMT
< Etag: W/"2d4-16179f127d8"
Etag: W/"2d4-16179f127d8"
< Last-Modified: Fri, 09 Feb 2018 09:41:43 GMT
Last-Modified: Fri, 09 Feb 2018 09:41:43 GMT
< Vary: Accept-Encoding
Vary: Accept-Encoding

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

~ $ docker run traefik version
Version:      v1.5.1
Codename:     cancoillotte
Go version:   go1.9.3
Built:        2018-01-29_02:14:02PM
OS/Arch:      linux/amd64

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

Default traefik container.

@ldez
Copy link
Contributor

ldez commented Feb 9, 2018

Thanks for your interest in Traefik 😃

The labels are case sensitive, you must use traefik.frontend.headers.customResponseHeaders=EXPR

http://docs.traefik.io/configuration/backends/docker/#security-headers

@ldez ldez closed this as completed Feb 9, 2018
@ldez ldez added kind/question a question and removed status/0-needs-triage labels Feb 9, 2018
@talolard
Copy link
Author

talolard commented Feb 9, 2018

Thanks for that amazingly fast response

@traefik traefik locked and limited conversation to collaborators Sep 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants