Load balancer with redirect to canonical hostname

I need a load balancer that redirects all incoming traffic to a particular hostname (the backend service requires this).

In general I would usually have a rule in the frontend

frontend blah

redirect prefix http://mydomain.com code 301 if ! { hdr(host) -i http://mydomain.com }

However, I having trouble getting this configured. Any suggestions?


Leaving this here for posterity or probably need to file a bug report.

It appears that wild card host matching rules do not work Selector rules in the load balancer UI or rancher-compose… Switching to the Service Rule with custom backend worked.