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。

can you help me with this syntax
“reqirep ^([^\ :])\ /(.) \1\ /SabPaisaAdminFe/\2” translation
-thanks in advance

Hi, thanks for explanation there.

I’m stuck with the same issue but not the same syntax unfortunately. Can you please help me to understand how to read something like this:
reqrep ^([^\ :])\ /(.) \1\ /1/\2

Moreover I need to translate it to http-request replace-path syntax;

I would highly appreciate literal translation, but actual explanation of what does this syntax means would be amazing.

I have just over 25 cases that I need to transfer from old to new, that all have different meaning. So I’d love to understand how to read it and translate it.

Thanks,
Vadim