Self hosting
Learn how to host MediaLit API
This guide explains how to self-host MediaLit with an S3-compatible storage provider.
Requirements
- Two buckets: one dedicated to private files and one to public files.
- Private bucket access settings: public access disabled.
- Public bucket access settings: public access enabled.
Configuring storage
AWS S3
1. Configure the private bucket

2. Configure the public bucket
2.1 Allow public access

2.2 Configure bucket policy
3. Set environment variables
Add CloudFront CDN
1. CloudFront distribution configuration
Add the public bucket to CloudFront as an origin.
2. Set environment variables
In this setup, private URLs are served directly from S3. To serve private bucket content via CloudFront as well, keep reading.
3. Put the private bucket behind CloudFront
3.1. Add the private bucket to CloudFront
Add the private bucket to CloudFront as an origin.

3.2. Set environment variables
Cloudflare R2
1. Configure the private bucket

2. Configure the public bucket

3. Set environment variables
In the Cloudflare setup, you cannot serve private bucket content through the CDN.