Search code examples
haproxy

Replace regrep for HAproxy 2.x


I need to administrate a server with a previously configured HAproxy v1.8. After updating to v2.4 I noticed the error about regrep not used anymore:

[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.

I was following some documentation but cannot really be sure I'm using the correct way to replace regrep. The configuration line in haproxy.cfg, in backend section:

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

What is the correct way to update it?


Solution

  • It looks to me that you want to replace the path.
    You can try the following, untested.

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

    More examples can be found in the doc http-request replace-path