HAProxy响应的集头

1.5版本中的新function是http-response add-header指令。 正如在文档中所写 – 这可以用在frontendbackendlisten

我正在尝试在frontend部分:

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

但是这没有效果。 放在backend部分的同一行工作得很好。 有人可以帮我理解,我在这里错过了什么? 我不明白,为什么这在frontend部分不起作用。

我的猜测是,在内部没有反应,所以指令失败。 我试着在use_backend指令前后使用它。

在前台运行haproxy( haproxy -d -V -f haproxy.cfg )并显示以下警告:

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

摆弄我的configuration,我发现这个警告显示在使用这个ACL时:

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

但是在使用这个ACL时不行:

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

resreq的区别在于,所以检查响应头而不是请求头。 这使我相信frontendhttp-response header规则不能检查request头。

我不知道这是否是HAProxy的预期function,但是它肯定没有被清楚地logging。