Prerequisites
Before you begin, you must have:- A device/server capable of running a web server (minimum 0.5GB of ram)
- A postgres database that your device can reach. (Serverless platforms like Neon works!)
- Installed Node.js (minimally v20.9.0) & Git
- Reasonable knowledge of git and using the terminal.
Get started
1
Install
Choose where Unified CDN should be stored, then clone the Unified CDN repository from Github on your device using git.Move to the project folder and install the dependencies using npm.
2
Setup configuration
Open up the project in a file manager and rename
.env.example to .env . On web servers, you can run mv .env.example .env instead.Open the .env file in a text editor. On web servers, run nano .env.3
Configure Authentication
We use BetterAuth for authentication.The variable Next, add the same URL to Example configuration:
BETTER_AUTH_URL is the URL of your Unified CDN instance, where you intend to host Unified CDN. For example:.env
TRUSTED_ORIGINS. There can be multiple origins if you intend to host Unified CDN on multiple domains:.env
BETTER_AUTH_SECRET is a secret key used to encrypt authentication details. This should be a random key. Use your own random key, or generate one:Afterwards, copy the generated key and paste it into the .env file. For example:.env
.env
4
Configure a database
Unified CDN uses a Postgres database, which are relational in nature and easier to develop with. You can use a Postgres database hosted on your server, a cloud service, or serverless platforms like Neon.
- Hosted postgres
- Serverless postgres
Follow the instructions provided by your hosting provider, or search online for a guide on creating a Postgres database.Once you have created a Postgres database, create a connection string in the
.env file. For example:.env
5
Configure deployment
Unified CDN can be ran in two ways: Node.js or Docker. Choose one of the two methods below, and set the This will be used later in the deployment step.
OUTPUT_METHOD variable in your .env file accordingly.- Node
- Docker
For running directly with
npm run start. This is the default..env
6
Test it
Congratulations, you have installed Unified CDN! If you want to, you can test your configuration before deploying to production. This is optional.Run the following command to start Unified CDN in development mode:Then, navigate to http://localhost:3000 on your machine (where you installed Unified CDN). You should load into a setup page, where you can complete the rest of the Unified CDN immediately.When the setup completes with no error, your configuration is valid, and you can proceed to deploying.