<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: J. Mark Locklear</title>
    <description>The latest articles on DEV Community by J. Mark Locklear (@marklocklear).</description>
    <link>https://dev.to/marklocklear</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F118998%2Fdc2f6716-8c09-40ed-9b31-21babf8e02c0.jpeg</url>
      <title>DEV Community: J. Mark Locklear</title>
      <link>https://dev.to/marklocklear</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/marklocklear"/>
    <language>en</language>
    <item>
      <title>Redirecting a domain with HTTPS using Amazon S3 and CloudFront</title>
      <dc:creator>J. Mark Locklear</dc:creator>
      <pubDate>Tue, 21 Jan 2020 17:14:58 +0000</pubDate>
      <link>https://dev.to/marklocklear/redirecting-a-domain-with-https-using-amazon-s3-and-cloudfront-526h</link>
      <guid>https://dev.to/marklocklear/redirecting-a-domain-with-https-using-amazon-s3-and-cloudfront-526h</guid>
      <description>&lt;p&gt;First off a big thanks to &lt;a href="https://twitter.com/weppos" rel="noopener noreferrer"&gt;Simone Carletti&lt;/a&gt; and &lt;a href="https://simonecarletti.com/blog/2016/08/redirect-domain-https-amazon-cloudfront/" rel="noopener noreferrer"&gt;his article on the topic&lt;/a&gt;. I basically ripped off everything from his article to create this one but with a little less detail and updated screenshots. Thank you Simone!&lt;/p&gt;

&lt;p&gt;The reason this process was helpful for me was that my organization had a bunch of legacy domains that we needed to remain active, but we wanted to redirect them to other domains. In addition we needed them to respond to https. Prior to this we have a bunch of servers that remained online for sole purpose of being able to respond and redirect https domains to other domains. This solution allowed us to take those servers offline.&lt;/p&gt;

&lt;p&gt;This whole process can take up to an hour assuming you get everything right the first time (you probably won't) so grab a Snickers and let's do this!&lt;/p&gt;

&lt;p&gt;The overall steps:&lt;br&gt;
-Configure S3 Bucket&lt;br&gt;
-Issue an SSL Certificate via Amazon Certificate Manager (ACM)&lt;br&gt;
-Configure Amazon CloudFront HTTPS redirect&lt;br&gt;
-Test records via CURL&lt;br&gt;
-Point the DNS record to CloudFront endpoint&lt;/p&gt;

&lt;p&gt;Let's dive right in!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Create a new Amazon S3 bucket:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F5vf9fvfqxflzx9kxxy7w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F5vf9fvfqxflzx9kxxy7w.png" alt="Create Bucket"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the first page enter the "Bucket Name" with the same name (without the http) as the origin domain (the domain name you want to redirect).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fom9y6ibb4phpyae7jodm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fom9y6ibb4phpyae7jodm.png" alt="Enter Domain Name"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now click through the rest of the settings keeping the defaults until you reach the "Create Bucket" button. Now click the "Create Bucket" button.&lt;/p&gt;

&lt;p&gt;Now back on the S3 main page click the name of the bucket you just created and click the "Properties" tab:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fjzinb4xaynunpcpb7t7e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fjzinb4xaynunpcpb7t7e.png" alt="Click Properties Tab"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now click the "Static website hosting" box:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fd3p7npowxvez2e0t193j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fd3p7npowxvez2e0t193j.png" alt="Click static website hosting"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On this page you want to choose "Redirect requests" and enter the target bucket (this is the domain name you want to redirect to) along with the protocol. One last thing before clicking save. Make note of the "Endpoint" on the page. Go ahead and copy the endpoint and paste it in a text editor. We will need this later. After entering that information click "Save":&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fe5odvolsn0ungujs9wue.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fe5odvolsn0ungujs9wue.png" alt="Set Properties"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Issue an SSL Certificate via Amazon Certificate Manager (ACM)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To create an SSL cert go to AWS Certificate Manager in AWS. &lt;strong&gt;Super important step here&lt;/strong&gt;, you must (or at least I had to) choose "US East(N. Virginia) from the drop-down in the upper right-hand corner of the AWS console:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Faq92lzg2rnrnizo7293c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Faq92lzg2rnrnizo7293c.png" alt="Choose Region"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now click "Get Started" under "Provision certificates":&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fgxw2jjmvrb9rxuj3cu3v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fgxw2jjmvrb9rxuj3cu3v.png" alt="Provision Certificates"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After clicking "Get Started" choose "Request a public certificate" then click the "Request a certificate" button:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fivbjmecunuh54iqiw64y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fivbjmecunuh54iqiw64y.png" alt="Request Certificate"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On Step 1 enter the domain you want to redirect (no http(s)) then click next:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fn1qs4t8dr8mx2dahxj73.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fn1qs4t8dr8mx2dahxj73.png" alt="Enter domain name"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On Step 2 choose "DNS Validation" (this is assuming you are using Route 53 or have access/ability to create DNS records for your domain) and choose next:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fw5g9b84fw4p3tr0i0ypa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fw5g9b84fw4p3tr0i0ypa.png" alt="DNS Validation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can choose the defaults for Steps 3 and 4 and finally click "Confirm and Request" at the end:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fpoublcogxxa896p97n41.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fpoublcogxxa896p97n41.png" alt="Confirm and request"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At this point, you should see something like "Pending validation" for the status of the certificate you just issued. The subsequent page should also give you CNAME record name and value to configure in your DNS provider. If you are using Route53 go to the Route53 console in AWS and click "Create Record Set" and in the "Name" section paste the "Record Name" value provided from Certificate Manager. For "Type" choose CNAME. For Alias choose "No" and in the "Value" box paste the "Record Value" value provided from the Certificate Manager. Here is what mine looks like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fg7rxik6em3seout0hv4n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fg7rxik6em3seout0hv4n.png" alt="Route 53 Config"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In a few minutes, the status over in the Certificate Manager should change to "Issued" for the Certificate you created.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F6oxjg7yqcj1ysp9b61gz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F6oxjg7yqcj1ysp9b61gz.png" alt="status changed"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Configure Amazon CloudFront HTTPS redirect&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Go to CloudFront Distributions in AWS and click the "Create Distributions" button:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F5tc5ve1ipqq8zwq3ps8o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F5tc5ve1ipqq8zwq3ps8o.png" alt="Create Distribution"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the next screen choose "Get Started" under "Web" for the delivery method:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fni7x01t0gekc0axfcjiy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fni7x01t0gekc0axfcjiy.png" alt="Delivery Method"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the subsequent page in the "Origin Domain Name" box insert the S3 endpoint you saved earlier. &lt;strong&gt;Do not use the auto-suggested endpoints that you see when you click in the box&lt;/strong&gt;. You need to use the endpoint displayed when you view the properties of the S3 bucket.&lt;/p&gt;

&lt;p&gt;Scroll down and find "Alternative Domain Names(CNAMEs)" and enter the domain name you want to redirect (no http).&lt;/p&gt;

&lt;p&gt;Next in the "SSL Certificate" section choose the "Custom SSL Certificate (example.com)" radio button and in the box below, when you click in the box amazon should auto-populate the text. Choose the certificate you created earlier. If it's not there, you missed a step earlier.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fsricbxtd3dh19s5txrre.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fsricbxtd3dh19s5txrre.png" alt="Custom SSL Certificate"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now click the "Create Distribution" button at the bottom of the page. The status should then be "In Progress" with a spinner; this may take a while, so go grab lunch. Once you see "enabled" as the status in CloudFront, then you can move forward with the steps below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fmgi7sljtfwh64xtp7en0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fmgi7sljtfwh64xtp7en0.png" alt="Create Distribution"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test records via CURL&lt;/strong&gt;&lt;br&gt;
Go to &lt;a href="https://dev.to/marklocklear/redirecting-a-domain-with-https-using-amazon-s3-and-cloudfront-1in3-temp-slug-6018498/edit"&gt;Simone's Article&lt;/a&gt; for details on using CURL to test your DNS records.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Point the DNS record to CloudFront endpoint&lt;/strong&gt;&lt;br&gt;
The final step is to go to Route53 (or your domain provider) and create a DNS record to redirect the hostname. Go to Route53 and click "Create Record Set". For the name enter the name of the host you want to redirect. Note that AWS will append the root domain for you if its a subdomain. The record type should be "A - IPv4 address". Set "Alias" to "Yes" and for "Alias Target" when you click in the text field it should be auto-populated with values from Cloudfront. Choose the appropriate Cloudfront distribution. Now click "Save Record Set":&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F1211l8mlbsqi5d5n1y06.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F1211l8mlbsqi5d5n1y06.png" alt="Create A Record"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So now you should have two records for the redirected domain. An A and a CNAME record. That's it! Hope this helps someone out.&lt;/p&gt;

&lt;p&gt;Happy Coding!&lt;/p&gt;

</description>
      <category>aws</category>
      <category>dns</category>
      <category>route53</category>
    </item>
  </channel>
</rss>
