基于响应状态代码

时间:2016-08-08 16:03:42

标签: load-balancing haproxy

如果它从后端服务器收到404响应,我试图让haproxy重定向到新位置。如果它没有收到404,我希望它能正常回应。

这对我来说很有意义,但似乎无法发挥作用:

frontend  front
    option httplog
    bind *:8080
    default_backend             app

backend app
    balance     roundrobin
    acl document_request path_beg -i /documents
    acl not_there status 404
    http-request redirect location http://newlocation/%[path] if document_request not_there
    server  webserver1 10.10.10.10:8080 check

我收到了以下警告:

acl' not_there'将永远不会匹配,因为它只涉及与后端http请求标头规则不兼容的关键字'

我在Centos 7上使用1.5.14版。

有关如何使这项工作的任何想法?是否有可能做我想做的事情?

非常感谢任何协助。

谢谢,

AL

1 个答案:

答案 0 :(得分:1)

http-request redirect根据检查请求的条件重定向请求(可选)。

status只能检查响应。 '与http请求标头规则不兼容'表示status仅与http响应规则兼容。

当您获得状态代码时,您只能重写其响应。 尝试使用http-response set-header resp编辑位置和状态。 set-status

从版本1.6开始,您可以使用http-response redirect

相关问题