download free 30 days trial version buy bucket explorer
Documentation  Download  Purchase  Support  FAQs   Forum   ScreenShots & Demos

CloudFront - How to Create Distributions with Custom Origins?

Custom Origin: Support for Custom Distribution lets Amazon CloudFront serve the content from any origin server that holds your content, which may be different from Amazon S3. Amazon CloudFront can use Amazon S3, Amazon EC2 instances or other data storage services as its origin server to serve the content. Custom Distribution can help when you don't want to use Amazon S3 as the Origin server. This is helpful for custom content management systems if you want to do object manipulation in your origin. With Bucket Explorer you can customize the origin information to associate with the distribution. You can create distribution for S3 Origin as well as Custom Origin (Non S3 Origin).

You can create a custom distribution, by sending HTTP POST Distribution Request to CloudFront Server, in one of the two ways explained below:

  1. Create custom distribution using REST API - "POST Distribution" : You will need to write your own code to create custom distribution using POST Distribution REST API.
  2. Create custom distribution using Bucket Explorer : To avoid writing multiple lines of code, you can create custom distribution with Bucket Explorer in just few mouse clicks.

1. Create Custom Distribution using REST API - "POST Distribution"

Syntax:


POST /2013-05-12/distribution HTTP/1.1
Host: cloudfront.amazonaws.com
Authorization: AWS authentication string
Date: time stamp
Other required headers

<?xml version="1.0" encoding="UTF-8"?>
<DistributionConfig xmlns="http://cloudfront.amazonaws.com/doc/2013-05-12/">
<CallerReference> unique description for this
distribution config </CallerReference>
<Aliases>
<Quantity> number of CNAME aliases </Quantity>
<!-- Optional. Omit when Quantity = 0. -->
<Items>
<CNAME> CNAME alias </CNAME>
</Items>
</Aliases>
<DefaultRootObject> URL for default root object </DefaultRootObject>
<Origins>
<Quantity> number of origins </Quantity>
<Items>
<Origin>
<Id> unique identifier for this origin </Id>
<DomainName> domain name of origin </DomainName>
<!-- Include the S3OriginConfig element only if
you use an Amazon S3 origin for your distribution. -->
<S3OriginConfig>
<OriginAccessIdentity>origin-access-identity/
cloudfront/ ID </OriginAccessIdentity>
</S3OriginConfig>
<!-- Include the CustomOriginConfig element only if
you use a custom origin for your distribution. -->
<CustomOriginConfig>
<HTTPPort> HTTP port that the custom origin
listens on </HTTPPort>
<HTTPSPort> HTTPS port that the custom origin
listens on </HTTPSPort>
<OriginProtocolPolicy>http-only |
match-viewer</OriginProtocolPolicy>
</CustomOriginConfig>
</Origin>
</Items>
</Origins>
<DefaultCacheBehavior>
<TargetOriginId> ID of the origin that the default cache behavior
applies to </TargetOriginId>
<ForwardedValues>
<QueryString>true | false</QueryString>
<Cookies>
<Forward>all | whitelist | none</Forward>
<!-- Required when Forward = whitelist,
omitted otherwise. -->
<WhitelistedNames>
<Quantity> number of cookie names to
forward to origin </Quantity>
<Items>
<Name> name of a cookie to forward to
the origin </Name>
</Items>
</WhitelistedNames>
</Cookies>
</ForwardedValues>
<TrustedSigners>
<Enabled>true | false</Enabled>
<Quantity> number of trusted signers </Quantity>
<!-- Optional. Omit when Quantity = 0. -->
<Items>
<AwsAccountNumber>self | AWS account that can create
signed URLs </AwsAccountNumber>
</Items>
</TrustedSigners>
<ViewerProtocolPolicy>allow-all |
https-only</ViewerProtocolPolicy>
<MinTTL> minimum TTL in seconds </MinTTL>
</DefaultCacheBehavior>
<CacheBehaviors>
<Quantity> number of cache behaviors </Quantity>
<!-- Optional. Omit when Quantity = 0. -->
<Items>
<CacheBehavior>
<PathPattern> pattern that specifies files that this
cache behavior applies to </PathPattern>
<TargetOriginId> ID of the origin that this cache behavior
applies to </TargetOriginId>
<ForwardedValues>
<QueryString>true | false</QueryString>
<Cookies>
<Forward>all | whitelist | none</Forward>
<!-- Required when Forward = whitelist,
omitted otherwise. -->
<WhitelistedNames>
<Quantity> number of cookie names to forward
to origin </Quantity>
<Items>
<Name> name of a cookie to forward to
the origin </Name>
</Items>
</WhitelistedNames>
</Cookies>
</ForwardedValues>
<TrustedSigners>
<Enabled>true | false</Enabled>
<Quantity> number of trusted signers </Quantity>
<!-- Optional. Omit when Quantity = 0. -->
<Items>
<AwsAccountNumber>self | AWS account that can create
signed URLs </AwsAccountNumber>
</Items>
</TrustedSigners>
<ViewerProtocolPolicy>allow-all |
https-only</ViewerProtocolPolicy>
<MinTTL> minimum TTL in seconds for files
specified by PathPattern </MinTTL>
</CacheBehavior>
</Items>
</CacheBehaviors>
<Comment> comment about the distribution </Comment>
<Logging>
<Enabled>true | false</Enabled>
<IncludeCookies>true | false</IncludeCookies>
<Bucket> Amazon S3 bucket to save logs in </Bucket>
<Prefix> prefix for log filenames </Prefix>
</Logging>
<ViewerCertificate>
<IAMCertificateId> IAM certificate ID </IAMCertificateId> |
<CloudFrontDefaultCertificate>true</CloudFrontDefaultCertificate>
</ViewerCertificate>
<PriceClass> maximum price class for the distribution </PriceClass>
<Enabled>true | false</Enabled>
</DistributionConfig>
 

2. Create Custom Distribution using Bucket Explorer


Follow these steps to Create Custom Distribution:


  1. Click on Distribution List Distribution tool button in Bucket toolbar.
  2. You will get the listing of distribution. To create new distribution, choose "New" icon from the toolbar of List distribution window.
  3. It will open a new window to create distribution. Select Download Distribution and click on Next.
  4. Now you will get the General Distribution Details panel.
  5. Here, fill in details like: Default Root Object, Price Class, CNAME, Comments, and set logging (Include Cookies [Optional]. Then Click on Next button.
  6. Now you will get the Origin panel. Here, select Non S3 Origin tab.
  1. Fill in here the required details:
    • DNS Name (For example: www.mysite.com)
    • HTTP port
    • HTTPS Port
    • Protocol policy: Http-Only or Match-Viewer.
  2. After entering these values, click on Add button to add these details in the below table.
  3. Now click on Next button.
  4. Now you will get Origin Details panel and Cache Behavior Details panel.
  5. Fill in desired details.
  6. Now click on Create button to create Custom Distribution.
Note: You can add multiple Origin Details (S3 or Non-S3) in Distribution.