Amazon CloudFront Integration with Ant Media Server
A content delivery network (CDN) is a geographically distributed network of proxy servers and data centers. The goal of a CDN is to provide high availability and performance by distributing content closer to end users.
This guide explains how to configure Amazon CloudFront to deliver HLS and LL-HLS streams from Ant Media Server.
What is Amazon CloudFront?
Amazon CloudFront is a web service that speeds up the distribution of static and dynamic web content. CloudFront delivers content through a global network of edge locations, automatically routing requests to the nearest location to reduce latency.
Prerequisites
Before configuring CloudFront, ensure you have:
- An AWS account
- A running instance of Ant Media Server, either launched from the AWS Marketplace or installed manually
- HLS enabled on your Ant Media Server instance
- The LL-HLS plugin installed if you want to play streams with LL-HLS
Configure Amazon CloudFront
Create a Distribution
-
Log in to your AWS account and open the Amazon CloudFront console.
-
Click Create Distribution.
-
Configure the origin:
- Origin domain: Enter the domain name of your Ant Media Server instance.
- Protocol: Choose HTTP (5080) or HTTPS (5443). If you select HTTPS, ensure SSL is enabled.
- Origin path: Enter the name of your Ant Media Server application (e.g.,
live).
-
Configure the default cache behavior:
-
Set cache behavior settings and policies as needed.
-
Attach a cache policy and origin request policy.
-
-
Disable the Web Application Firewall (WAF) protection for this distribution if not required.
-
Complete creation of the distribution and wait for it to deploy.
Configuring Error Pages
-
In the CloudFront console, open your distribution and go to the Error Pages tab.
-
Create a custom error response for 404: Not Found.
-
Set Error Caching Minimum TTL to 3 seconds.
-
-
Once deployed, note your CloudFront domain name.
Publish a Live Stream with Ant Media Server
- Follow the Publish Live Stream guide to start a stream.
- For this example, publish an RTMP stream using OBS.
Play the Live Stream with HLS
Use the following format for HLS playback:
http://your_cloud_front_domain_name/play.html?id=your_stream_id&playOrder=hls
Example:
http://d3m1pdd4lln4vj.cloudfront.net/play.html?id=stream01&playOrder=hls
Play the Live Stream with LL-HLS
Use the following format for LL-HLS playback:
http://your_cloud_front_domain_name/play.html?id=your_stream_id&playOrder=ll-hls
Example:
http://d3m1pdd4lln4vj.cloudfront.net/play.html?id=stream001&playOrder=ll-hls
Congratulations!
By completing these steps, you have:
- Deployed Ant Media Server on AWS.
- Configured Amazon CloudFront to deliver HLS and LL-HLS streams.
- Published and tested playback of live streams through CloudFront.
You can now deliver live video globally with reduced latency and improved reliability using Amazon’s CDN infrastructure.