Replace path not working

Hi,

On haproxy version HA-Proxy version 2.2.20-1ppa1~bionic 2022/01/12 , (Ubuntu 18.04.3 LTS) we are trying to rewrite a complete request so that we can hit the backend server.

http-request set-header Host api.back.server.com
http-request replace-path /pathv2 /v1

server back1 api.back.server.com:443 ssl check cookie s1 sni req.hdr(Host) verify none

The problem is when I open the URL from browser:

https://www.domain1.com/pathv2/session/login/action

It gets rewritten into:

https://api.back.server.com/pathv2/session/login/action

The /pathv2 isn’t changed and it should be. Any idea why?

I have also tried with regsub but it’s the same:
http-request set-path “%[path,regsub(^/pathv2,/v1,i)]”

please try:

http-request replace-path /pathv2/(.*) /v1\1

https://cbonte.github.io/haproxy-dconv/2.2/configuration.html#http-request%20replace-path

best regards,
Markus