Can I use a single Amazon CloudFront web distribution to serve content from multiple origins using multiple behaviors?

Yes, you can configure a single CloudFront web distribution to serve different types of requests from multiple origins. For example, if you are building a website that serves static content from anAmazon Simple Storage Service (Amazon S3) bucket and dynamic content from a load balancer, you can serve both types of content from a CloudFront web distribution.

Follow these steps to configure a CloudFront web distribution to serve static content from an S3 bucket and dynamic content from a load balancer:

  1. Open your web distribution from the Amazon CloudFront console.
  2. Choose the Origins view.
  3. Create one origin for your S3 bucket, and another origin for your load balancer.
    Note: If you're using a custom origin server or an S3 website endpoint, you must enter the origin's domain name into the Origin Domain Name field.
  4. From your distribution, choose the Behaviors view.
  5. Create a behavior that specifies a path pattern to route all static content requests to the S3 bucket. For example, you can set the "images/*.jpg" path pattern to route all requests for ".jpg" files in the images directory to the S3 bucket.
  6. Edit the Default (*) path pattern behavior and set its Origin as your load balancer.

Did this page help you? Yes | No

Back to the AWS Support Knowledge Center

Need help? Visit the AWS Support Center.

Published: 2018-05-11