How to self-host 🌸Blossom server/drive and Dive Into Decentralized Nostr Storage

How to self-host 🌸Blossom server/drive and Dive Into Decentralized Nostr Storage

What's Blossom?

Blossom offers a bunch of HTTP endpoints that let Nostr users stash and fetch binary data on public servers using the SHA256 hash as a universal ID.

You can find more -precise- information about Blossom on the Nostr article published today by hzrd149, the developper behind it:

https://yakihonne.com/article/naddr1qqxkymr0wdek7mfdv3exjan9qgszv6q4uryjzr06xfxxew34wwc5hmjfmfpqn229d72gfegsdn2q3fgrqsqqqa28e4v8zy

You find the Blossom github repo here:

GitHub - hzrd149/blossom: Blobs stored simply on mediaservers
Blobs stored simply on mediaservers. Contribute to hzrd149/blossom development by creating an account on GitHub.

Meet Blobs

Blobs are files with SHA256 hashes as IDs, making them unique and secure. You can compute these IDs from the files themselves using the sha256 hashing algorithm (when you run sha256sum bitcoin.pdf).

Meet Drives

Drives are like organized events on Nostr, mapping blobs to filenames and extra info. It's like setting up a roadmap for your data.

How do Servers Work?

Blossom servers have four endpoints for users to upload and handle blobs:

  • GET /<sha256>: Get blobs by their SHA256 hash, maybe with a file extension.
  • PUT /upload: Chuck your blobs onto the server, verified with signed Nostr events.
  • GET /list/<pubkey>: Peek at a list of blobs tied to a specific public key for smooth management.
  • DELETE /<sha256>: Trash blobs from the server when needed, keeping things tidy.

Yon can find detailed information about the Blossom Server Implementation here..

blossom/Server.md at master · hzrd149/blossom
Blobs stored simply on mediaservers. Contribute to hzrd149/blossom development by creating an account on GitHub.

..and the Blossom-server source code is here:

GitHub - hzrd149/blossom-server: Blobs stored simply on mediaservers
Blobs stored simply on mediaservers. Contribute to hzrd149/blossom-server development by creating an account on GitHub.

What's Blossom Drive?

Think of Blossom Drive as the "Front-End" (or a public cloud drive) of Blossom servers, letting you upload, manage, share your files/folders blobs.

Source code is available here:

GitHub - hzrd149/blossom-drive: A cloud drive built using blossom servers
A cloud drive built using blossom servers. Contribute to hzrd149/blossom-drive development by creating an account on GitHub.

Developpers

If you want to add Blossom into your Nostr client/app, the blossom-client-sdk explaining how it works (with few examples 🙏) is published here:

GitHub - hzrd149/blossom-client-sdk: A simple client for managing blobs on blossom servers
A simple client for managing blobs on blossom servers - hzrd149/blossom-client-sdk

How to self-host Blossom server & Blossom Drive


We'll use docker compose to setup Blossom server & drive. I included Nginx Proxy Manager because it's the Web Proxy I use for all the Fractalized self-hosted services :

Create a new docker-compose file:

~$ nano docker-compose.yml

Insert this content into the file:

version: '3.8'
services:

  blossom-drive:
    container_name: blossom-drive
    image: pastagringo/blossom-drive-docker
#    ports:
#      - '80:80'

  blossom-server:
    container_name: blossom-server
    image: 'ghcr.io/hzrd149/blossom-server:master'
#    ports:
#      - '3000:3000'
    volumes:
      - './blossom-server/config.yml:/app/config.yml'
      - 'blossom_data:/app/data'
      
  nginxproxymanager:
    container_name: nginxproxymanager
    image: 'jc21/nginx-proxy-manager:latest'
    restart: unless-stopped
    ports:
      - '80:80'
      - '81:81'
      - '443:443'
    volumes:
      - ./nginxproxymanager/data:/data
      - ./nginxproxymanager/letsencrypt:/etc/letsencrypt
      - ./nginxproxymanager/_hsts_map.conf:/app/templates/_hsts_map.conf

volumes:
  blossom_data:

You now need to personalize the blossom-server config.yml:

~$ mkdir blossom-server
~$ nano blossom-server/config.yml

Insert this content to the file (CTRL+X & Y to save/exit):

# Used when listing blobs
publicDomain: https://blossom.fractalized.net

databasePath: data/sqlite.db

discovery:
  # find files by querying nostr relays
  nostr:
    enabled: true
    relays:
      - wss://nostrue.com
      - wss://relay.damus.io
      - wss://nostr.wine
      - wss://nos.lol
      - wss://nostr-pub.wellorder.net
      - wss://nostr.fractalized.net
  # find files by asking upstream CDNs
  upstream:
    enabled: true
    domains:
      - https://cdn.satellite.earth # don't set your blossom server here!

storage:
  # local or s3
  backend: local
  local:
    dir: ./data
  # s3:
  #   endpoint: https://s3.endpoint.com
  #   bucket: blossom
  #   accessKey: xxxxxxxx
  #   secretKey: xxxxxxxxx
  #   If this is set the server will redirect clients when loading blobs
  #   publicURL: https://s3.region.example.com/

  # rules are checked in descending order. if a blob matches a rule it is kept
  # "type" (required) the type of the blob, "*" can be used to match any type
  # "expiration" (required) time passed since last accessed
  # "pubkeys" (optional) a list of owners
  # any blobs not matching the rules will be removed
  rules:
    # mime type of blob
    - type: text/*
      # time since last accessed
      expiration: 1 month
    - type: "image/*"
      expiration: 1 week
    - type: "video/*"
      expiration: 5 days
    - type: "model/*"
      expiration: 1 week
    - type: "*"
      expiration: 2 days

upload:
  # enable / disable uploads
  enabled: true
  # require auth to upload
  requireAuth: true
  # only check rules that include "pubkeys"
  requirePubkeyInRule: false

list:
  requireAuth: false
  allowListOthers: true

tor:
  enabled: false
  proxy: ""

You need to update few values with your own:

  • Your own Blossom server public domain / upstream domains where Nostr clients will also verify if the Blossom server own the file blob:
publicDomain: https://YourBlossomServer.YourDomain.tld
  upstream:
    enabled: true
    domains:
      - https://cdn.satellite.earth
  • The Nostr relays where you want to publish your Blossom events (I added my own Nostr relay):
discovery:
  # find files by querying nostr relays
  nostr:
    enabled: true
    relays:
      - wss://nostrue.com
      - wss://relay.damus.io
      - wss://nostr.wine
      - wss://nos.lol
      - wss://nostr-pub.wellorder.net
      - wss://nostr.fractalized.net

Everything is setup! You can now compose your docker-compose file:

~$ docker compose up -d

I will let your check this article to know how to configure and use Nginx Proxy Manager.

You can check both Blossom containers logs with this command:

~$ docker compose logs -f blossom-drive blossom-server

Regarding the Nginx Proxy Manager settings for Blossom, here is the configuration I used:

PS: it seems the naming convention for the kind of web service like Blossom is named "CDN" (for: "content delivery network"). It's not impossible in a near future I rename my subdomain blossom.fractalized.net to cdn.blossom.fractalized.net and blossom-drive.fractalized.net to blossom.fractalized.net 😅.

Do what you prefer!

After having configured everything, you can now access Blossom server by going to your Blossom server subdomain. You should see a homepage as below:

Same thing for the Blossom Drive, you should see this homepage:

You can now login with your prefered method. In my case, I login on Blossom Drive with my NIP-07 Chrome extension.

You now need to go the "Servers" tab to add some Blossom servers, including the fresh one you just installed.

You can now create your first Blossom Drive by clicking on "+ New" > "Drive" on the top left button:

Fill your desired blossom drive name and select the media servers where you want to host your files and click on "Create":

PS: you can enable "Encrypted" option but as hzrd149 said on his Nostr note about Blossom:

"There is also the option to encrypt drives using NIP-49 password encryption. although its not tested at all so don't trust it, verify"

You are now able to upload some files (a picture for instance):

And obtain the HTTP direct link by clicking on the "Copy Link" button:

If you check URL image below, you'll see that it is served by Blossom:

It's done ! ✅

You can now upload your files to Blossom accross several Blossom servers to let them survive the future internet apocalypse.

Blossom has just been released few days ago, many news and features will come!

Don't hesisate to follow hzrd149 on Nostr to follow-up the future updates ⚡🔥

See you soon in another Fractalized story!
PastaGringo 🤖⚡