I have a subdomain in Amazon Route53. Let's say secure.example.com
If requests come like https://secure.example.com
it is ok but I would like to force http
requests to come through https. When user types http://secure.example.com
it needs to be forwarded to https://secure.example.com
.
Is there a domain level redirecting/forwarding requests coming through http
to https
in Amazon Route53
?
No, there is no way to do this -- because it's not a DNS function to force any particular protocol, or to push values from one protocol to another. You can do this easily enough at the web server level, either in Apache, or IIS, or NGINX.
In any of those cases, the A or CNAME value pointing a specific record to a specific address (whether an IP or another host name) is the same, it's just going to connect via port 80 or port 443.
In Apache, you can simply use a rewrite (enable mod_rewrite
first):
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://www.host.com/$1 [R]
Just a quick update for this question. Whilst in answer to your question no, you can't use route 53 to force HTTPS, this would lead some people to believe that forcing https on AWS hosting wasn't possible.
You can create a SSL certificate in Certificate Manager(or import your own), host your website where ever(S3/EC2), you then need to setup a CloudFront distribution for your site and import your SSL certificate, you can then force HTTPS via the behaviour tab in the CloudFront console.