I’m attempting to come up with something to accept traffic on www.
and redirect it the naked domain (so it’s clear it’s not used).
frontend port[80|443] from httpees
...
http-request set-var(txn.txnhost) hdr(host)
acl nowwwredir var(txn.txnhost) -m beg -i www.
http-request redirect location http://%[req.hdr(Host),lower,regsub(www\.,,i)] code 30[1|2|3] if nowwwredir
...
…or:
frontend port[80|443] from httpees
...
http-request set-var(txn.txnhost) hdr(host)
http-request redirect location http://%[req.hdr(host),lower,regsub(www\.,,i)] code 30[1|2|3] if { var(txn.txnhost) -m beg -i www. }
...
I’m not completely sure if the unnamed ACL is correct. Anyway, while I have worked out everything to be as generic as possible and do have separate http://** and https:// frontends to infer the schemes, I’d like to replace the target scheme with an expression too, if possible. What would this be?
I’m open to different methods or other advise.
Sidenote
I considered the other redirects too but it quickly became confusing when the
prefix
keyword appeared because I’ve seen several definitions forlocation
that are up there with the definition of URL vs URI (something I forget about while reading about it): 1. theURL
fromscheme
topath
, 2. thepath
, when it’s called a relative URL, 3. once again refers to thepath
bothhttpd
’s andnginx
’s documentation. Then comes prefix` which in most software I’ve encountered that asks for this, it refers to the beginning of the path for reverse-proxy-awareness but here it seems that this can be the whole URI up to the query part or nothing but rather some construct for cookie injection depending on how is it written and have seen examples where it can replace everything but can’t make sense of them. Finally there’s an option for scheme only but I think that would needs to be its own ACL.
**
e.g; for things like OCSP, root CA’s public key, non-DNS ACME, Profile Manager (initial contact), device provisioning, …