We use an S3 bucket and Route 53 alias record to redirect domain.com
to www.domain.com
on a DNS level. This works with http, but does not work with https requests.
There are TXT and MX records for domain.com, so we cannot use a CNAME. The www.domain.com
is a CNAME to our Elastic Beanstalk server.
The domain.com
cannot be an A record since the server's IP address is not fixed.
What works:
- curl http://domain.com => 301 redirect to http://www.domain.com
- curl http://www.domain.com => 301 redirect to https://www.domain.com
- curl https://www.domain.com => served by the EB server
What does not work:
- curl https://domain.com => curl: (7) Failed connect to domain.com:443; Connection refused
How to redirect https://domain.com to https://www.domain.com? Or alternatively what should we do with the TXT and MX records so we can use a CNAME record?