在Ubuntu 14.04上使用haproxy 1.4.24版
我想使用haproxy重写和重定向不再对其新等效项有效的URL.我已经在使用haproxy作为反向代理和负载均衡器.我有重写正常工作,但当我尝试重定向时,我最终没有重定向或重定向循环.我在几个地方读到,一种技术是在前端使用前缀重写和重定向url,但我没有运气.任何帮助,将不胜感激.谢谢.
global log 127.0.0.1 local0 log 127.0.0.1 local1 notice maxconn 4096 user haproxy group haproxy spread-checks 0 defaults log global mode http option httplog option dontlognull retries 3 timeout queue 20000 timeout client 50000 timeout connect 5000 timeout server 50000 frontend haproxy-0-80 bind 0.0.0.0:80 default_backend haproxy_service acl old_url path_beg -i /post # The below doesn't appear to have any effect reqrep ^([^\ :]*)\ /post/\d+/(.+)/? \1\ /\2 redirect prefix http://10.0.3.10 code 301 if old_url backend haproxy_service balance leastconn cookie SRVNAME insert # The below properly handles the rewrite reqrep ^([^\ :]*)\ /post/\d+/(.+)/? \1\ /\2 server ghost-0-2368 10.0.3.220:2368 maxconn 100 cookie S0 check
事实证明我非常接近工作配置.
如果old_url使其按预期工作,则将重定向行更改为读取重定向前缀/代码301.
我写了一篇博文,更详细地概述了这个问题:https://fromanegg.com/post/2014/12/05/how-to-rewrite-and-redirect-with-haproxy/
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。