OPNsense Forum

Archive => 17.7 Legacy Series => Topic started by: Webxorcist on November 27, 2017, 01:26:05 pm

Title: HAProxy redirect root to www subdomain
Post by: Webxorcist on November 27, 2017, 01:26:05 pm
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?
Title: Re: HAProxy redirect root to www subdomain
Post by: Webxorcist on November 27, 2017, 03:52:47 pm
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.

Title: Re: HAProxy redirect root to www subdomain
Post by: Webxorcist on November 30, 2017, 03:29:38 pm
1. Place this in your Frontend 'Option pass-through' with Advanced options turned on:
Code: [Select]
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