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

CloudFront - How to Create Distributions with Multiple Origin Servers (POST Distribution with multiple Origins)?

In Amazon CloudFront, your content is organized as "Distributions". A distribution is a link between an Amazon S3 bucket (the origin server) and a domain name (assigned by Amazon CloudFront ), and it tells you what are the locations of the original versions of your files. CloudFront is basically used for faster content delivery. If you have large volume of data in the cloud (Amazon S3 File), which is requested by the users frequently, it will be much faster to access same object via CloudFront than accessing from the original source, S3 Bucket. When the object is requested for the first time, CloudFront copies the Object from S3 origin to the nearest edge location and next time when user requests for that object, it is delivered from the nearest edge location instead of the Origin server Amazon CloudFront allows to create a distribution for single origin as well as multiple origin.

Dynamic Content Delivery

Dynamic Content Delivery offers a simple and cost-effective way to improve the entire website’s performance, reliability and global reach.
CloudFront works like Amazon EC2's running applications. You can also use Amazon CloudFront distribution to deliver both the static and dynamic content of your website. With that, there is no need to separate the static and dynamic content of your website or manage multiple domain names. With Dynamic Content Delivery, you can also include query string parameters or cookies to customize your web pages. You can also configure multiple cache behavior for your download distribution. Dynamic Content Delivery is not only simple but is also a more usable and reliable service.

These features are described below:
  1. Cache Behavior
    With Amazon CloudFront’s Dynamic Content Delivery, you can configure multiple cache behaviors for your download distribution. You can include these configuration values: origin server name, viewer connection protocol, minimum expiration period, query string parameters, cookies and trusted signers in cases of private content in each cache behavior.
  2. Origin Servers
    With Dynamic Content Delivery, you can configure one or more origin servers for your Amazon CloudFront Distribution to allow flexibility in using each AWS resource. With that, there is no need to create multiple distributions and manage multiple domain names on your website.
  3. Low TTLs
    When delivering dynamic content, Amazon CloudFront uses expiration period, which can be set to as low as 0 seconds, to check if it needs an updated version of the file. When delivering dynamic content that may not be cached at the edge, CloudFront also uses special cache control directives like private, no-store, etc.
  4. Query String Parameters
    Query string parameters can help you customize your web pages and at the same time, you take advantage of the benefits offered by caching content at Amazon CloudFront Edge locations.
  5. HTTP Cookies
    When delivering customized or personalized dynamic content, you can use HTTP Cookies. With HTTP Cookies, you can specify whether you want Amazon CloudFront to forward all of your cookies to your origin server or only some of them. When CloudFront identifies a unique object in its cache, it also considers the forwarded cookie values.

To Create Distribtuion you can do some sort of settings, like which type of distibution you want to create ( Download / Streaming ), then mention Origins for which you want to create distribution and after that define Cache Behavior for the each Origin. You can also set Default Root, Logging for the distribution, CNAME, Min TTL, Connection Type (Secure/Non Secure), Trusted Signers, make private the origin access by adding Origin Access Identity ID.

You can create the CloudFront Distribution with multiple origin server one of the two ways:

  1. Create CloudFront Multiple Origin Server Distribution with CloudFront API- POST Distribtion - If you are a programmer, you can write your own code, to use AWS CloudFront supported API- POST Distribution in your code to create CloudFront Multi Origin Distribution.
  2. Create CloudFront Multiple Origin Server Distribution using Bucket Explorer - You can create CloudFront Distribution using Bucket Explorer User Interface if you do not want to write software code.

1. Create multi domain download distribution using Amazon CloudFront REST API

Creating Multi Origin Server distribution needs to add details for each origin in distribution configuration XML. Here is a sample of code with POST Request :

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 multi domain download distribution using Bucket Explorer

Bucket Explorer supports AWS CloudFront's " Dynamic Content Delivery " at no additional cost. With this feature, you can deliver personalized, dynamic web content without writing a single line of code, no up-front fees, and no monthly platform fees.

When you go to create Download Distribution, You will find four steps 
  1. Distribution Type
  2. General Distribution Details
  3. Origin Details
  4. Cache Behavior Details
Dynamic content delivery distribution How to create multi domain download distribution for dynamic content delivery?
  • Run Bucket Explorer.
  • Choose "Distribution →List Distribution" icon from Bucket table toolbar or you can do the same by selecting "Manage Distribution" option from right click menu option of any bucket.
  • It displays a "Distribution" window with list of already created distributions..
  • To create new distribution,choose "New" icon from toolbar of Distribution window.
  • It opens a new window to create distribution. Now you need to set configuration for public distribution.

Step 1. Distribution Type

  • Here you will have two options. One Download Distribution and another one is Streaming Distribution.
    Here you have to select the distribution type "Download Distribution"

Step 1 : Select Distribution Type
Step 2 : Add General Settings Step 2. General Distribution Details
  • Default Root Object  [ Optional ]  : Enter Default Root Object  if you want to make any file default (for default Origin Cache Behavior - Details added at Step 4)
  • CNAME  [Optional]  : Enter CName Entry if you want to add. You can enter upto 10 CName entries here.
  • Price Class : Select any on mode PriceClass_All (Default Value ), PriceClass_200, PriceClass_100
  • Logging  [Optional]  : You can also add Logging setting details here, where you want to get created distribution logging with file having prefix so and so. So You can mention Bucket Name and Log File Name Prefix here.
  • Comments [Optional]: Enter comment about this distribution.
  • After entering all required entries, press Next Button.
Step 3. Origin Details
  • Here you will find two tabs. 1. S3 Origin 2. Non-S3 (Custom) Origin, Select S3 Origin tab.
  • Now you have to select Bucket as S3 Origin
    • Do not make any selection for Origin Access Identitiy Details - Only for Private Download Distribution
    • Now Press Add Button S3 Origin details.
  • Now click on Non S3 Origin Tab
    • Enter your domain name outside of AWS like bucketexplorer.com etc.
    • Enter Port for Secure and Non Secure connect
    • Choose protocol policy for custom origin Http-Only / Match Viewer.
    • Now Press Add Button to add custom origin details.  
  • You can add number of origins as you want to merge in a distirbution.
  • After entering all required entries, press Next Button.
Step 3 : Add Origin Details

Finish : Add Cache Behavior Details Step 4. Cache Behavior Details
  • Targeted Origin ID : To associate the cache behavior with origin, you have to select the targeted origin id or select any bucket; both are associated with each other.
  • Path Pattern : You can add Path pattern for cache behavior ( Not Applicable for Default Cache Behavior)
  • Trusted Signer : Keep trusted signer disabled (Uncheck the Trusted Signer Checkbox)
  • Viewer Protocol Policy : Select either Allow All or Https Only.
  • Cookies Setting : You can set Query String option enabled or disabled as per your requirements. Select Forward Type - All, None or White List.
  • Min TTL : You can set min TTL for distribution from 0-0 to ~3,153,600,000 seconds.
  • Default : If Origin table has one entry then here, Cache Behavior will have to be set as default.
  • When, for all domains, there is one entry in Cache Behavior details table, press Create button to create Distribution.
  • Finally, you have created Download Distribution for faster dynamic content delivery.

Default Root Object : You can use Bucket Explorer to assign a default object for your distribution. A default object is a file that is designated as the object for Amazon CloudFront to return in response when a user requests to your distribution's root URL instead of a specific object in your distribution.
AWS S3 Origin : It refers to Amazon S3 Bucket like mybucket.s3.amazonaws.com
Non S3 Origin : It refers to any domain other than Amazon S3 Bucket, like bucketexplorer.com, sdbexplorer.com etc.