Quantcast
Channel: HAProxy community - Latest topics
Viewing all articles
Browse latest Browse all 4733

Removing "www."; what (expression) replaces the scheme?

$
0
0
TLDR; text in bold.

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. :slight_smile:



Sidenote (click for more details) ** (click for more details)

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 4733

Trending Articles