HAProxy community

The 'reqrep' directive is deprecated in favor

Hi,

we are upgrading haproxy fleet from v1.8.22 to v2.0.8. In that process we saw lot of logging:
The 'reqrep' directive is deprecated in favor of 'http-request replace-uri' and 'http-request replace-header' and will be removed in next version.

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 501 not implemented on from our backend server. But on older version 1.8.22 it’s working as it should.

Example:

backend name:
    #reqrep ^([^\ :]*)\ /abc/(.*) \1\ /\2
     http-request replace-uri ^([^\ :]*)\ /abc/(.*) \1\ /\2
     server  server_name A.B.C.D:PORT

What are we doing wrong?

You need to adapt your regex with replace-uri. your reqrep rule captured the method and the part of the path you wanted, you don’t match the method in http-request replace-uri, only uri.

http-request replace-uri /abc/(.*) /\1

Hi,

thanks for reply.

Is there a way to limit the replace-uri only from the begining of the uri? If I use it like this, it will replace all /abc/ and I want replace only on the beginning
https://www.example.com/abc/cde/xyz/abc -> https://www.example.com/cde/xyz/abc

my bad, it should have been:
http-request replace-uri ^/abc/(.*) /\1

Jerome,

Thx for the help :slight_smile: