Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

New in version 1.5 is the http-response add-header directive. As written in the documentation -- this can be used in frontend, backend and listen.

What I was trying to within a frontend section:

use_backend some_backend                if some_condition
http-response add-header Vary Origin    if some_condition

But this has no effect. The same line placed in the backend section works perfectly fine. Can someone please help me understand, what I am missing here? I don't understand, why this does not work in the frontend section.

My guess would be that within the fronted there is no response yet and so the directive fails. I tried using it before and after die use_backend directive.

share|improve this question
up vote 4 down vote accepted

Running haproxy in foreground (haproxy -d -V -f haproxy.cfg) with your sample displayed the following warning:

acl 'some_condition' will never match because it only involves keywords that are incompatible with 'frontend http-response header rule'

Fiddling with my config, I found that this warning is displayed when using this ACL:

acl some_condition req.hdr(Content-Type) -i application/json

But not when using this ACL:

acl some_condition res.hdr(Content-Type) -i application/json

The difference being res vs. req, so checking response headers instead of request headers. This leads me to believe that a http-response header rule in a frontend is incapable of inspecting request headers.

I don't know if this is intended functionality by HAProxy, but it certainly hasn't been clearly documented.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.