# Always set HTTP response header?

**URL:** <https://discourse.haproxy.org/t/always-set-http-response-header/2491>\
**Category:** Help!\
**Created:** [May 12, 2018, 1:00pm UTC](https://discourse.haproxy.org/t/always-set-http-response-header/2491 "2018-05-12T13:00:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mag](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@mag](https://discourse.haproxy.org/u/mag)\
**Post date:** [May 12, 2018, 1:00pm UTC](https://discourse.haproxy.org/t/always-set-http-response-header/2491/1 "2018-05-12T13:00:21Z")

</div>

Hello,  
HAProxy 1.7.10 (pfSense) here.  
I’ve got a TLS/SSL enabled frontend that’s configured to unconditionally send the Strict-Transport-Security HTTP response header, e.g.

```
http-response set-header Strict-Transport-Security "max-age=31536000; includeSubDomains"

```

This works, but only for successful responses (from the HAProxy point of view).  
If there’s a HAProxy generated error response such as HTTP 503, the header is missing and I’d like to have it there as well.

For example Apache has the **always** condition its the Header directive designed for such purpose: [http://httpd.apache.org/docs/current/mod/mod\_headers.html#header](http://httpd.apache.org/docs/current/mod/mod_headers.html#header)

```
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"

```

Is it somehow possible to achieve this with HAProxy?

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [May 13, 2018, 7:54am UTC](https://discourse.haproxy.org/t/always-set-http-response-header/2491/2 "2018-05-13T07:54:27Z")

</div>

Unfortunately this is not currently possible the easy way.

A few possible workarounds are:

- use custom error pages and insert the header manually there (the custom error pages must contain the entire HTTP response, including HTTP headers) - however this still does not cover haproxy redirects, if you are using that
- Iterate through a dedicated frontend/backend section for the purpose of adding the header, use the second layer proxying for load-balancing, errors, etc, so that when an error is generated in the second layer, the first layer will be responsible for adding the header
