Skip to content

S3 Integration and HTTP Forwarding

Murat Ugur Eminoglu edited this page May 17, 2022 · 3 revisions

Attention: We have migrated our documentation to our new platform, Ant Media Resources. Please follow this link for the latest and up-to-date documentation.

In this document, we are going to see How we can record streams to S3 compatible systems(OVH, Digital Ocean, Wasabi) and Configure HTTP forwarding.

Using S3 services is more cost-effective than storing files on your own server. It’s also easy to manage. Furthermore, S3 services have a lot of API capabilities. For example, you can add CORS policies, rules, and triggers to your system.

Table of Contents

Record streams to AWS S3

In order to programmatically access to S3, you should have an access token and secret keys. You can create a programmatic user to have an access token and secret key from AWS IAM(Identity and Access Management) console.

Add User in IAM

Just Add User by checking Programmatic Access box and then in the next section click Attach existing policies directly and add AmazonS3FullAccess access permission to this user. Copy access token and secret key for this user.

Add User in IAM detail

  • Right now, you should have access token, secret key, bucket name in your hand.

You also need to know the region of your bucket. If you do not have any bucket, you can create it on S3 Console

bucket 1

bucket 2

bucket 4

Here you see the sample S3 credentials. You need to set to yours:

Then, log in the http://your_ams_server:5080, enable the Record Live Streams as MP4 and Enable S3 Recording, enter the S3 credentials you have created and save the settings.

Your MP4 files and Preview files will be uploaded to your S3 Storage automatically.

Record streams to OVH Object Storage

OVH is a cost-effective cloud provider and it is preferred by many people. If you installed Ant Media Server on an OVH cloud instance, you may want to upload your stream recordings to S3 storage. You could do that with a few steps. Let start!

Firstly, you need to generate Secret Key and Access Key with your OpenStack username/password. You can learn more about it in OVH's docs.

After generating Secret Key and Access, you just need to create an Object Storage as an image.

You will see the Dashboard below after clicking the Create the Container.

Here you see the sample S3 credentials. You need to set to yours:

Then, log in the http://your_ams_server:5080, enable the Record Live Streams as MP4 and Enable S3 Recording, enter the S3 credentials you have created and save the settings.

Your MP4 files and Preview files will be uploaded to your OVH Object Storage automatically.

Record streams to Digital Ocean Spaces

DigitalOcean is another cloud provider that is preferred by many Ant Media Server users. You could integrate your DigitalOcean cloud instance easily with S3 cloud storage. Let’s see how it can be done with a few steps!

Firstly, you need to create Spaces. Just click the Space button and fill in the blanks.

After creating Spaces you need to create API keys for Access and Secret keys. Just click the API button on the left side and then click Generate New Key.

Just type the Name parameter and click the create button.

After generating Access keys and Secret keys, there is only one step left.

Then, log in the http://your_ams_server:5080, enable the Record Live Streams as MP4 and Enable S3 Recording, enter the S3 credentials you have created and save the settings.

Your MP4 files and Preview files will be uploaded to your Digital Ocean Spaces automatically.

Record streams to Wasabi Storage

Wasabi is another cloud provider that is preferred by many Ant Media Server users. You could integrate your Wasabi storage. Let’s see how it can be done with a few steps!

Firstly, you need to create a new access key in your Wasabi account.

After generating Access keys and Secret keys, you need to create a bucket. Just click the Create Bucket on the right side.

Then, log in the http://your_ams_server:5080, enable the Record Live Streams as MP4 and Enable S3 Recording, enter the S3 credentials you have created and save the settings.

Your MP4 files and Preview files will be uploaded to your Wasabi storage automatically.

HTTP Forwarding

HTTP forwarding is implemented to forward incoming HTTP requests to any other place. It's generally used for forwarding incoming request to a storage like S3.

Let us tell how HTTP Forwarding works step by step

  • Open the file {AMS-DIR} / webapps / {APPLICATION} / WEB-INF / red5-web.properties with your text editor (vim, nano)
  • Add comma separated file extensions like this settings.httpforwarding.extension=mp4,png to the file.
  • Add the base URL with settings.httpforwarding.baseURL=https://{YOUR_DOMAIN} for forwarding.

Usage Example:

  • If you are using AWS S3 bucket, {YOUR_DOMAIN} will be like:

{s3BucketName}.s3.{awsLocation}.amazonaws.com

  • If you are using Digital Ocean Spaces, {YOUR_DOMAIN} will be like:

{BucketName}.{BucketLocation}.digitaloceanspaces.com

Note: Don't add any leading, trailing white spaces.

  • Save the file and restart the Ant Media Server with sudo service antmedia restart

If it's configured properly, your incoming MP4 requests such as https://{SERVER_DOMAIN}:5443/{APPLICATION_NAME}/streams/vod.mp4 will be forwarded to https://{YOUR_DOMAIN}/streams/vod.mp4

How to play AWS S3 VOD files with Embedded Web Player

If you would like to embedd the VODs stored in AWS S3 bucket, you need to configure CORS parameters on AWS S3 Bucket Permissions

CORS parameters of AWS S3 bucket should be modified so that the requests that are coming from another origins to play the VODs can be processed.

  • Go to your AWS -> Services -> S3 -> Buckets -> "Your Bucket" -> Permissions -> And at the bottom of the page there is Cross-origin resource sharing (CORS). The CORS configuration, written in JSON, defines a way for client web applications that are loaded in one domain to interact with resources in a different domain."

Click Edit-> and paste the code provided below:

[
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "HEAD",
            "GET",
            "PUT",
            "POST",
            "DELETE"
        ],
        "AllowedOrigins": [
            "*"
        ],
        "ExposeHeaders": []
    }
]

"*" on the origin field as is it accepts requests from all origins, it can be used for quick-testing. However, it can be changed for allowing permissions for exact origins, such as "http://www.your-domain.com" since you only want to accept requests that are coming from your end.

Conclusion:

In this blog post, we learned how easily we can integrate Ant Media Server with S3 storage and configure HTTP forwarding to play the VOD files. By following this blog post, you could start uploading MP4, WebM, and preview records to your storage automatically.

User Guide

Reference

Troubleshooting

Draft

Proposals

Clone this wiki locally