# CustomResponseHeader using go template

**URL:** <https://community.traefik.io/t/customresponseheader-using-go-template/19141>\
**Category:** Traefik v2\
**Tags:** docker, middleware\
**Created:** [July 5, 2023, 7:08pm UTC](https://community.traefik.io/t/customresponseheader-using-go-template/19141 "2023-07-05T19:08:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rdoering](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/rdoering/32/7304_2.png) [@rdoering](https://community.traefik.io/u/rdoering)\
**Post date:** [July 5, 2023, 7:08pm UTC](https://community.traefik.io/t/customresponseheader-using-go-template/19141/1 "2023-07-05T19:08:28Z")

</div>

Given docker compose file

```auto
version: "3.9"

services:
  platform:
    image: registry.dev.int.quentic.com/proxy/traefik/whoami
    ports:
      - 80
    deploy:
      replicas: 3
    labels:
      - "traefik.enable=true"
      # @see https://doc.traefik.io/traefik/providers/docker/#defaultrule
      - "traefik.http.middlewares.cluster-hostname.headers.customresponseheaders.X-Cluster-Hostname=Host({{ `Hello Docker World` }})"
      # Apply the middleware named `cluster-hostname` to the router named `router1`
      #- "traefik.http.routers.route1.middlewares=cluster-hostname@docker"
      - "traefik.http.routers.route1.middlewares=cluster-hostname@docker"

  traefik:
    image: registry.dev.int.quentic.com/proxy/library/traefik:2.9
    ports:
      - "127.0.0.1:81:80"
      - "127.0.0.1:8181:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./traefik/conf.d:/etc/traefik/conf.d
    healthcheck:
      test: ["CMD", "traefik", "healthcheck"]
      interval: 3s
    environment:
      - TRAEFIK_LOG_LEVEL=${TRAEFIK_LOG_LEVEL:-INFO}
      - TRAEFIK_API_DASHBOARD=true
      - TRAEFIK_API_INSECURE=true
      - TRAEFIK_GLOBAL_CHECKNEWVERSION=false
      - TRAEFIK_PROVIDERS_FILE_DIRECTORY=/etc/traefik/conf.d
      - TRAEFIK_PROVIDERS_DOCKER_DEFAULTRULE=Host(`{{ .Name }}.localhost`)
      - TRAEFIK_PROVIDERS_DOCKER_USEBINDPORTIP=true
      - TRAEFIK_PROVIDERS_DOCKER_EXPOSEDBYDEFAULT=false
      - TRAEFIK_ENTRYPOINTS_http_ADDRESS=:80
    labels:
      - "traefik.enable=true"
      - "traefik.http.middlewares.cluster-hostname.headers.customresponseheaders.X-Cluster-Hostname={{ normalize .Name }}"

```

When I call `curl -v --location platform-reverse.localhost:81` I receive:

```auto
* connect to ::1 port 81 failed: Connection refused
* Trying 127.0.0.1:81...
* Connected to platform-reverse.localhost (127.0.0.1) port 81 (#0)
> GET / HTTP/1.1e
> Host: platform-reverse.localhost:81
> User-Agent: curl/7.81.0
> Accept: */*l
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OKt
< Content-Length: 379p
< Content-Type: text/plain; charset=utf-8
< Date: Wed, 05 Jul 2023 19:05:17 GMT
< X-Cluster-Hostname: Host({{ `Hello Docker World` }})
<
{ [379 bytes data]
 100 379 100 379 0 0 109k 0 --:--:-- --:--:-- --:--:-- 123k
* Connection #0 to host platform-reverse.localhost left intact
Hostname: 86cd5edd70ee
IP: 127.0.0.1
IP: 172.26.0.3
RemoteAddr: 172.26.0.2:46448
GET / HTTP/1.1
Host: platform-reverse.localhost:81
User-Agent: curl/7.81.0
Accept: */*
Accept-Encoding: gzip
X-Forwarded-For: 172.26.0.1
X-Forwarded-Host: platform-reverse.localhost:81
X-Forwarded-Port: 81
X-Forwarded-Proto: http
X-Forwarded-Server: 5baa4a469c7e
X-Real-Ip: 172.26.0.1

```

As you see, the Go template code is not resolved and left unchanged `Host({{ `Hello Docker World` }})`

What can I do to get the ContainerName as the value of the response header `X-Cluster-Hostname`?
