HAProxy community

The 'reqrep' directive is not supported anymore since HAProxy 2.1

we are upgrading haproxy fleet from v1.8.14 to v2.1.4,But we can’t start haproxy:

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.

So we decided to ditch reqrep and in that process the same regex that was working with reqrep is not working with the http-request replace-uri.
We got 404 not implemented on from our backend server. But on older version 1.8 it’s working as it should.
Example:

#reqrep ^([^\ ]\ /)api/rdc[/]?(.) \1api/\2
http-request replace-uri ^([^\ ]\ /)api/rdc[/]?(.) \1api/\2

What are we doing wrong?

It can replace it, but it is not a 1:1 replacement.

reqrep replaces the entire request line, replace-path replaces the path only and replace-header would be for a normal header line, not the request line.

Looks like you want to replace /api/rdc/ with /api/, try:

http-request replace-path /api/rdc(.*) /api\1

Thx for the help ,bro,this is right。