为 HAproxy 替换 regrep 2.x

Replace regrep for HAproxy 2.x

我需要使用之前配置的 HAproxy v1.8 来管理服务器。更新到 v2.4 后,我注意到有关 regrep 不再使用的错误:

[ALERT]    (1574) : parsing [/etc/haproxy/haproxy.cfg:310] : The 'reqrep' directive is not supported anymore since HAProxy 2.1. Use 'http-request replace-path', 'http-request replace-uri' or 'http-request replace-header' instead.

我正在阅读一些文档,但不能真正确定我使用的是正确的方法来替换 regrep。 haproxy.cfg中的配置行,在后端部分:

  reqrep ^([^\ :]*)\ /amc[/]?(.*)  \ //

正确的更新方法是什么?

我看你是想替换路径。
您可以尝试以下未经测试的方法。

http-request replace-path /amc[/]?(.*) /

可以在文档中找到更多示例http-request replace-path