satellite-cdn is a blossom compatible gateway for Cloudflare R2 object storage. It accepts lightning payments from users, allowing them to prepay for data hosting. The overall goal of this project is to increase decentralization and competition among media hosts in the nostr ecosystem.
Live instance deployed at https://cdn.satellite.earth
Once you've created an Cloudflare R2 bucket, clone this repo project on your server.
cd satellite-cdn
npm i
Before starting Satellite CDN, you'll need to configure it by adding a .env
file that looks something like this:
DB_PATH=/path/to/db/directory
S3_BUCKET=dev
S3_ACCESS_KEY_ID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
S3_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CF_ACCOUNT_ID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
APP_SECRET_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
STORAGE_RATE_USD=0.05
LIGHTNING_PROVIDER_PUBKEY=79f00d3f5a19ec806189fcab03c1be4ff81d18ee4f653c88fac41fe03570f432
LIGHTNING_CALLBACK_URL=https://getalby.com/lnurlp/myapp/callback
CDN_ENDPOINT=http:https://localhost:5050
BLOB_ENDPOINT=https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.r2.dev
LISTENER_RELAYS=wss:https://relay.damus.io,wss:https://nos.lol,wss:https://relay.snort.social,wss:https://relay.nostrplebs.com,wss:https://relay.plebstr.com,wss:https://relay.nostr.band,wss:https://nostr.wine
DB_PATH
is the directory where the CDN's embedded SQLlite database livesS3_BUCKET
is the name of your R2 bucketS3_ACCESS_KEY_ID
is your access token id generated by CloudflareCF_ACCOUNT_ID
is your public cloudflare account IDAPP_SECRET_KEY
is your secret access token generated by CloudflareSTORAGE_RATE_USD
is the number of cents per gigabyte, per month, that customers will be charged to store data on the CDNLIGHTNING_PROVIDER_PUBKEY
is the pubkey of the lightning server your customer's will be sending payments to, and the CDN will be listening forCDN_ENDPOINT
is the base url endpoint of your CDN (e.g.https://cdn.satellite.earth
)BLOB_ENDPOINT
is the base url endpoint of where the blobs are actually served from (e.g.https://blob.satellite.earth
)LISTENER_RELAYS
are a set of relays to which your CDN will maintain a persistant connection, listening for customer payments
To start the CDN, run
npm start
If your using a reverse proxy such as Nginx, you made need to configure the request max body size to a higher value to prevent larger uploads from failing.