HAProxy community

How to remove query string with reqrep in Haproxy backend?

I am trying to write a reqrep query to try and strip out a query string. I am using ACLs with urlp_end to direct to the correct backend, but the query string that is being used for that is being passed over to the backend.

The frontend uses an ACL like this:

acl Test_ACL urlp_end(device) -m str eq 14110
use_backend Device_1 if Test_ACL

In my backend I just have the server IP, but i would like to remove the device parameter in the backend. Here is an example:

https://example.com/chkimg/FRONT200GRAY8_1.JPG?device=14110

This forwards to the right backend. Basically all i want to do is in the backend traffic, strip the “?device=______” parameter from the URL, so that it just forwards this to the backend, with the entire device parameter invisible to the backend server:

https://example.com/chkimg/FRONT200GRAY8_1.JPG

Is there any way in the backend that I can remove everything after the “?”.

Try:

http-request set-uri %[path]

Well that was easy. It works! Thank you!