How do I change path for backend

I have a path I’m using to identify itself to for an acl but I need a different path for the backend server. How do I remove the first three characters of the path before passing to the backend? passed in the path is /rd/asdffdsa1213 and to the backend server it should be /asdffdsa123.

backend backend-http
    option forwardfor
    server web-1 site.website1.com:80 check

Is that possible? I saw an example using this.

http-request set-uri %[url,regsub(^/rd,/,)]

Is that the right approach? I tried it but it gave me an error. It may be the version of haproxy.

[root@pm-prod-haproxy01 b738cbea49eaded323220988d9e184ee]# haproxy -f /etc/haproxy/haproxy.cfg
[ALERT] 163/161449 (10421) : parsing [/etc/haproxy/haproxy.cfg:45]: 'http-request' expects 'allow', 'deny', 'auth', 'redirect', 'tarpit', 'add-header', 'set-header', 'replace-header', 'replace-value', 'set-nice', 'set-tos', 'set-mark', 'set-log-level', 'add-acl', 'del-acl', 'del-map', 'set-map', but got 'set-uri'.
[ALERT] 163/161449 (10421) : Error(s) found in configuration file : /etc/haproxy/haproxy.cfg

[root@pm-prod-haproxy01 b738cbea49eaded323220988d9e184ee]# haproxy -v
HA-Proxy version 1.5.18 2016/05/10
Copyright 2000-2016 Willy Tarreau <willy@haproxy.org>

[root@pm-prod-haproxy01 b738cbea49eaded323220988d9e184ee]#

You need at least 1.6 for the http-request set-uri feature.

Take a look at reqrep, you can likely cover your use case with that.

Ok, thanks! I’ve seen that the regex engine is a performance penalty. Should I continue that direction or upgrade? I’m just using the vanilla version from centos 7. Seems like it’s best to update to latest anyway now that I see it’s 1.8.

How much the performance penalty is due to the regex is depends on the expression. Your set-uri example in the first post is just another regex - so whether you use that or reqrep really does not matter.

Also the performance penalty is very likely minuscule.

1 Like