Unnecessary redirects for HTTPS
My recently configured droplets are exhibiting some unnecessary redirects and I cannot figure out why.
End result should https://domain.com
So I need to rewrite www requests and non-https requests to https without the www.
Currently the opposite is happening, and adding an extra redirect which is costing about an extra 1 second.
My NGINX server blocks looks like this:
servername domain.com www.domain.com;
return 301 https://$servername$request_uri;
listen 443 ssl;
ssl_certificate /path/to/fullchain.pem; ssl_certificate_key /path/to/privkey.pem; root /path/to/html; index index.php; server_name domain.com www.domain.com; #additional configurations
Some additional information:
- SSL cert is for both non-www and www
- A name pointing to IP, with WWW CNAME pointing to domain.com.
- Total of 3 sites with the same configuration. Only 1 redirects properly. Incidentally it’s also the only site not currently pointing to Cloudflare DNS. I suspect this might be the source of my issues.
Any help would be greatly appreciated. This is the last roadblock to sub-second load times.