Help with Regex

HAProxy receives an header called “X-Cf-Forwarded-Url” with value https://new-hello-app.apps.px-npe.cf.xxx.com/greeting?name=sen and when HAproxy making backend server call, need to capture “new-hello-app.apps.px-npe.cf.xxx.com” 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?

Hello,

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