HAProxy reqrep 不替换 url 中的字符串

标签 haproxy

我们弃用了一些在 http://localhost/test 下可用的软件现在可以在 http://localhost/app/testing 下使用.我们正在使用 HAProxy 1.4
因此,我想通过 haproxy,替换所有包含 /test 的网址与 /app/testing/ .我首先尝试使用 redirect prefix为了保留查询字符串,但是/test没有从 url 中删除并且有类似 /app/testing/test/?id=x 的内容.

frontend all
    bind  0.0.0.0:80
    timeout client 86400000
    acl is_test path_beg /test
    redirect prefix /app/testing code 301 if is_test

然后用了 reqrep ,这似乎重定向到新软件,但 /test url 中的字符串永远不会被替换。
frontend all
    bind  0.0.0.0:80
    timeout client 86400000
    reqrep ^([^\ :]*)\ /test[/]?(.*)  \1\ /app/testing/\2

最佳答案

由于 1.4 版无法重写 url 并且我们不想更新 HAProxy,因此我们继续使用 reqrep并保持旧链接不变

reqrep ^([^\ :]*)\ /test[/]?(.*)  \1\ /app/testing/\2

关于HAProxy reqrep 不替换 url 中的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40972885/

相关文章:

amazon-s3 - HaProxy透明代理到AWS S3静态网站页面

mysql - 在 EC2 服务器上使用 HAProxy 负载平衡 MySql

routes - Kubernetes 集群的外部负载均衡器

Redis哨兵故障转移配置问题

regex - 使用重定向配置重写 HAProxy 和 reqrep 路径

http - 具有 ssl 和简单 acl 的 HAProxy http 模式表现异常

web-services - haproxy 1.5 特定源 IP 地址在 haproxy 日志中显示 <NOSRV> 503 SC

ssl - HAProxy 负载均衡器 : Peer's Certificate issuer is not recognized

security - HAProxy 是否默认保护自己免受 tcp syn flood 攻击

varnish - 具有haproxy的多个 Varnish 服务器