Problem with DNS


#1

Hi -

Summary

I’ve been developing on and off the web for a long time, but my DNS knowledge is low, I’m new to load balancers, and I have very little understanding of https and certificates.

I’m using a DH registered domain on an AWS-hosted site.

I have two specific questions based on the behavior I’m observing:

why would http://domainname redirect to http://www.domainname, but https://domainname does not redirect to https://www.domainname?
why would https://www.domainname resolve correctly, but https://domainname returns Server Not Found?

Read on for further details, as well as changes I’ve made/attempted to correct these issues (successfuly, in some, but not all cases).

Thanks in advance for any help that anybody can provide.

Details

I need all of these URLs to resolve to https://www.domainname

http://domainname/
https://domainname/
http://www.domainname/
https://www.domainname/

I’ve had the particular domain name registered here at DH for years. It was previously fully hosted (here at DH).

I changed it from fully hosted to DNS only, and I created a *.domainname CNAME record (at DH) pointing to my AWS LB.

Initial behavior:

http://domainname/ redirects to http://www.domainname/
https://domainname/ Server not found
http://www.domainname/ OK
https://www.domainname/ OK

Note that I made no manual changes to DNS or apache configs to get http://domainname/ to redirect to http://www.domainname/. So I don’t understand why/where that was happening.

I added a https rewrite rule in the apache.conf files on the ec2 instances, leading to the following improvements in behavior:

http://domainname/ redirects to https://www.domainname/
http://www.domainname/ redirects to https://www.domainname/

This left only https://domainname/ not resolving correctly

In attempting to resolve this, I tried adding another CNAME record (without a subdomain name) pointing to the LB, but got an error saying that CNAME records were only valid for subdomains.

I came across https://ryans.dream.press/dns-3/custom-dns-records/point-domain-only-using-cname-record/ and followed its instructions to “set your domain to redirect to the www subdomain of the site… on the Manage Domains Page”