I am trying to conditionally prepend a subdomain to the path.
Incoming https://<subdomain>.mysite.com/<path>
This should become https://<subdomain>.mysite.com/<subdomain>/<path>
but only if the path does not already start with . For example:
https://abc.mysite.com/jungle
should become https://abc.mysite.com/abc/jungle
but https://abc.mysite.com/abc/jungle
should not be changed.
I have this in haproxy.cfg
. It correctly isolates the subdomain in var(req.store_id)
but it prepends to the path enve if the store_id
acl insti_prod hdr_reg(host) -i [^.]*.mysite.com
http-request set-var(req.store_id) req.hdr(host),lower,regsub(\.mysite\.com$,) if insti_prod
# Pre-pend subdomain to the path if not already there
http-request set-path /%[var(req.store_id)]%[path] if { var(req.store_id) -m found } !{ path_beg /var(req.store_id) }
Where am I going wrong??
Thanks!