puppet-nginx
puppet-nginx copied to clipboard
Redirect non-www to www
We have numerous platforms where the preferred hostname is with the www. - this is either from a marketing point of view, or for technical reasons (uses an ELB or CDN that needs to be pointed to a CNAME record but the apex record can only be an A record, so it'll hit example.org (direct) and then get redirected to www.example.org which will come back through the CDN/ELB.
The rewrite_www_to_non_www does the exact reverse of what we're after and while we're currently solving by doing a separate vhost housing the custom redirect, this would be a much more graceful approach.
You know, I had always thought that it actually was the opposite already (embarrassing, because I'm pretty sure I did some updates related to that feature). I agree that this is definitely a common use-case, maybe the more common one.
I don't have time / energy to implement this personally, but I do think this is a good idea.
This turned out to be a much bigger headache than I thought it would be; that said, there is #1105 available for review. I'll see if I can get some suggestions to see if there's a way to simplify this or make it easier to read / follow.
If you'd like to do any functional testing from that branch (or apply the patch from it), feel free to test.