# Http-response set-header

**URL:** <https://discourse.haproxy.org/t/http-response-set-header/5435>\
**Category:** Help!\
**Created:** [July 5, 2020, 6:36pm UTC](https://discourse.haproxy.org/t/http-response-set-header/5435 "2020-07-05T18:36:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![driiper](https://avatars.discourse-cdn.com/v4/letter/d/c67d28/32.png) [@driiper](https://discourse.haproxy.org/u/driiper)\
**Post date:** [July 5, 2020, 6:36pm UTC](https://discourse.haproxy.org/t/http-response-set-header/5435/1 "2020-07-05T18:36:11Z")

</div>

Hi, I am experimenting with using the http-response command, specifically the following line:  
`http-response set-header X-Server %s`

The configuration is as follows:

```
listen proxies-in
  bind 0.0.0.0:18509
  bind :::18509
  mode tcp
  default_backend proxies
  balance roundrobin

backend proxies
  mode HTTP
  http-response set-header X-Server %s
  server 127.0.0.1:15050 127.0.0.1:15050 check
  server 127.0.0.1:15051 127.0.0.1:15051 check

```

The goal here is that I would like to see the X-Server header added to the header and should indicate the server used to handle the request. I’ve seen configurations doing this but the X-Server is not added for my requests.

Client -\> HaProxy Load balancing -\> HTTPS Page --\> HaProxy add header --\> client.

Is this possible?

If this is not possible, How can I perform tasks given a specific HTTP Status code? For example run commands if i get status code 400 (lua or python)

---

<div class="post-metadata">

**Author:** ![en666](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/en666/32/2225_2.png) [@en666](https://discourse.haproxy.org/u/en666)\
**Post date:** [May 29, 2024, 12:11pm UTC](https://discourse.haproxy.org/t/http-response-set-header/5435/2 "2024-05-29T12:11:23Z")

</div>

Answering here for future reference; on haproxy 2.7 the following works:

```auto
backend highly-available-service
        mode http
        option forwardfor
        option redispatch
        http-response set-header X-Server %s
        server server_uk3 127.0.0.1:8080 check
        server server_uk1 86.162.112.12:443 check-ssl ssl backup weight 20

```

I can see the ‘X-Server’ header in the response valued ‘server\_uk3’ or ‘server\_uk1’ depending on the choice haproxy makes.
