elpado
elpado

Reputation: 73

Is it possible to overwrite "server name" response header in traefik?

I'm setting up a new server with Traefik (version 1.7.10) for load balancing different NGINX and PHP-FPM containers.

Currently visitors see in the response header that my containers using NGINX. Where can I globaly, for all containers, overwrite the server response header to something other (like "FunnyServer") ?

With HAProxy I have done this in the past and wondering how to do this with Traefik?

Here you see the response coming from HAProxy:

cache-control: no-store, no-cache, must-revalidate, post-check=0, 
pre-check=0
content-type: text/html; charset=utf-8
date: Wed, 17 Apr 2019 20:20:15 GMT
expires: Thu, 19 Nov 1981 08:52:00 GMT
pragma: no-cache
server: MonkeysBananaServer    <===== WITH HAPROXY!!! Traefik??? 
set-cookie: PHPSESSID=1234567890abcdef; path=/; domain=.xxx.xx
status: 200
x-powered-by: PHP/x.x.x

As you can see, under HAProxy I have set the response header to "MonkeysBananaServer".

Upvotes: 3

Views: 4057

Answers (2)

ldez
ldez

Reputation: 3128

You can override the response headers:

traefik.frontend.headers.customResponseHeaders=server:FunnyServer

https://docs.traefik.io/v1.7/configuration/backends/docker/#custom-headers

Upvotes: 1

glebovdev
glebovdev

Reputation: 402

For those who use version 2.0 and have the same question:

- "traefik.http.middlewares.secure-headers.headers.customresponseheaders.x-powered-by=SomeThing/9.7.2"
- "traefik.http.routers.custom_router_name.middlewares=secure-headers"

Upvotes: 4

Related Questions