load-balancing - haproxy 基于响应状态码重定向

标签 load-balancing haproxy

如果 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请求 header 规则”不兼容的关键字

我在 Centos 7 上使用版本 1.5.14。

关于如何实现这项工作有什么想法吗?可以做我想做的事吗?

任何帮助将不胜感激。

谢谢

AL

最佳答案

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

status 只能检查响应。 “与 http-request header 规则不兼容”表示 status 仅与 http-response 规则兼容。

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

从版本 1.6 开始,您可以使用 http-response 重定向

关于load-balancing - haproxy 基于响应状态码重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38833822/

相关文章:

Magento 负载平衡 - 附加许可证

cors - Haproxy CORS No 'Access-Control-Allow-Origin' header is present on the requested resource

java - Haproxy + 网络 : Way to prevent exceptions on connection reset?

mysql - 使用 Marathon 在 Mesos 上部署 Mysql

linux - haproxy 绑定(bind)命令将密码包含在 haproxy.cfg 文件中

linux - Ubuntu Linux 和 Crossroads 负载均衡器不太工作

url - www和www1,www2,www3等之间有什么区别

javascript - 未能在已部署的 emberjs 应用程序上的资源的 'integrity' 属性中找到有效的摘要

amazon-web-services - 如何配置 AWS 网络负载均衡器以实现端到端 HTTPS 加密,同时保持 session 关联性?

session - session 亲和性和粘性 session 之间的区别?