Help with Regex

HAProxy receives an header called “X-Cf-Forwarded-Url” with value and when HAproxy making backend server call, need to capture “” from X-Cf-Forwarded-Url and set it to “Host” header.

Can someone help with this regex, which need to be used in backend section?


You can give a try with this :

http-request set-header host %[req.hdr(X-Cf-Forwarded-Url),regsub(\"(https?://)(.*)(/.*)\",\"\2\",i)] if { req.hdr(X-Cf-Forwarded-Url) -m found }

Not sure about the efficiency, but quick test seem OK on version 2.2