Skip to content

Instantly share code, notes, and snippets.

@beardedtim
Created February 17, 2020 17:51
Show Gist options
  • Save beardedtim/becf1919f82b8865e46cbb14fc02fc4d to your computer and use it in GitHub Desktop.
Save beardedtim/becf1919f82b8865e46cbb14fc02fc4d to your computer and use it in GitHub Desktop.
How to test that a CloudFront Distrobution works as intended

How to check that a cloudfront distro will work

Problem

You have some Elastic Beanstalk/Load Balancer that you want to attach multiple domains to. You want to use Route 53 to point to a CloudFront Distrobution, which will point at the ELB/EBS.

Solution

  • Go to Cloudfront
  • Create a new distro
  • BE SURE TO FORWARD ALL HEADERS/COOKIES/QUERY STRINGS/EVERYTHING POSSIBLE TO ORIGIN
  • Set the CNames/SSL as needed

Once the distro is created,

  • Run nslookup <cloudfront url> to get the IP address of the cloudfront server

  • edit your /etc/hosts file and add <ip address of cloudfront> <domain you are trying to set up>

    • For instance, if you wanted to test abc.com and Cloudfront's IP is 1.2.3.4, you would add the following line to /etc/hosts:
    1.2.3.4 abc.com
    
  • Now in your browser/using cURL, make a request to abc.com. You should see the origin server responding to your requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment