HAProxy redirect root to www subdomain

Started by Webxorcist, November 27, 2017, 01:26:05 PM

Previous topic - Next topic
I have several webservers behind HAProxy. I use the LetsEncrypt pluging that also redirects poort 80 to 443. I tried to redirect a domain.com to www.domain.com but I can't seem to get it working. Perhaps I am even thinking in the wrong direction.

What would be a decent way to configure this? I had my front-end also listen to domain.com as well as to www.domain.com and then an acl and action that put www. in front of the domain. But so far no go.

Also, would you need an ACL and action per domain or it is possible to do it all with one?

November 27, 2017, 03:52:47 PM #1 Last Edit: November 27, 2017, 04:04:51 PM by Webxorcist
Ok so you don't need an ACL. Just a listen in the frontend.

Apparently I came to the above conclusion to soon. It still isn't working.


1. Place this in your Frontend 'Option pass-through' with Advanced options turned on:
redirect prefix http://www.yourdomain.eu code 301 if { hdr(host) -i yourdomain.eu }
2. Add the domain to the Listen addresses
3. If needed adjust the certificate to also support the domain without www