Create a Reverse Proxy and Cache Using Amazon CloudFront

To support AMP pages over HTTPS using a CNAME, a reverse proxy must be set up.

To configure a reverse proxy and HTTP cache using an Amazon CloudFront web server, the following steps must be performed.

This procedure assumes that you have a working web server configured with a CNAME. For the purposes of this tutorial, the CNAME example.com is used. 

1 - Create a new distribution on Cloudfront

  1. Access https://console.aws.amazon.com/cloudfront/home?region=eu-west-1#distributions
  2. Click the Create Distribution button. 
  3. When prompted, select Web as the delivery method.

2 - Origin settings

  1. In the Origin Domain Name field, enter the DNS entry that will be provided to you by the Customer Success team. For the purpose of this tutorial, example.com is used as a placeholder.  
  2. The Origin ID is automatically set to Custom-example.com.
  3. In the Origin Protocol Policy section, select Match Viewer.

3 - Default cache behavior settings

In the Default Cache Behavior Settings:

  1. Select HTTP and HTTPS in the Viewer Protocol Policy section.
  2. Select Use Origin Cache Headers in the Object Caching section.
  3. Select None in the Forwarding Cookies field.
  4. Select None in the Query String Forwarding and Caching field. 

4 - Distribution settings

  1. For optimal performance, set Price Class to Use All Edge Locations.
  2. In the case of alternate domain names, you must list any custom domain names (in this case, example.com) that you use in addition to the CloudFront domain name (for example, d1234.cloudfront.net) for the URLs for your files. Specify up to 100 CNAMEs separated with commas or put each on a new line. You must also create a CNAME record with your DNS service to route queries for example.com to d1234.cloudfront.net.
  3. If you select to enable logging, you would need to create a Bucket in the S3 Console, required to store web server logs. This is also where you will select that bucket.
  4. Set Distributon State to Enabled.

5 - Create distribution

Finallyclick the Create Distribution button, which should elicit the following message:

A domain name has been generated for your CloudFront distribution: d**************q7.cloudfront.net.

The service is now syncing with your site. The Status will change to "Deployed" once it completes, and that usually takes about 10 minutes.