Use Ghost blog to serve your Nostr NIP05 and BTC LNURL

Use Ghost blog to serve your Nostr NIP05 and BTC LNURL

Welcome to a new Fractalized episode of "it works but I can do better"!

Few day ago, I wanted to set my Ghost blog (this one) as root domain for Fractalized instead of the old basic Nginx container that served my NIP05. I succeed to do it with Nginx Proxy Manager (I need to create a blog post because NPM is really awesome) but my NIP05 was down.

Having a bad NIP05 on Amethyst is now in the top tier list of my worst nightmares.

As a reminder, to have a valid NIP05 on your prefered Nostr client, you need to have a file named "nostr.json" in a folder ".well-known" located in the web server root path (subdomain or domain).
The URL shoud look like this http://domain.tld/.well-known/nostr.json

PS : this doesn't work with Ghost as explained later. If you are here for Ghost, skip this and go directly to 1).

You should have these info inside the nostr.json file (JSON format) :

{
  "names": {
    "YourUsername": "YourNPUBkey"
  }
}

You can test it directly by going to the nostr.json URL, it should show you the JSON.

It was working like a charm on my previous Nginx and I needed to do it on my new Ghost.
I saw on Google that I need to have the .well-known folder into the Ghost theme root folder (In my case I choosed the Solo theme). I created the folder, put my nostr.json file inside it and crossed my fingers. Result : 404 error.

I had to search a lot but it seems that Ghost forbid to server json file from its theme folders. Maybe for security reasons, I don't know. Nevertheless Ghost provide a method to do it (but it requires more than copy/paste some files in some folders) => routes

In the same time that configuring your NIP05, I also wanted to setup an LNURL to be zapped to pastagringo@fractalized.ovh (configured into my Amethyst profile). If you want more infromation on LNURL, it's very well explained here.

Because I want to use my Wallet of Satoshi sats wallet "behind" my LNURL, you'll have to read carefuly the EzoFox's blog post that explains how to retrieve your infos from Alby or WoS.

1) Configuring Ghost routes


Add the new route into the routes.yaml (accessible from "Settings" > "Labs" > "Beta features" > "Routes" ; you need to download the file, modify it and upload it again) to let him know where to look for the nostr.json file.

Here is the content of my routes.yaml file :

routes:
  /.well-known/nostr.json/:
    template: _nostr-json
    content_type: application/json
  /.well-known/lnurlp/YourUsername/:
    template: _lnurlp-YourUsername
    content_type: application/json
collections:
  /:
    permalink: /{slug}/
    template: index

taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/

=> template : name of the file that ghost will search localy
=> content_type : file type (JSON is required for the NIP05)

The first route is about my NIP05 and the second route is about my LNURL.

2) Creating Ghost route .hbs files


To let Ghost serve our JSON content, I needed to create the two .hbs file filled into the routes.yaml file. These files need to be located into the root directory of the Ghost theme used. For me, it was Solo.

Here is there content of both files :

"_nostr-json.hbs"

{
  "names": {
    "YourUsername": "YourNPUBkey"
  }
}

"_lnurlp-pastagringo.hbs" (in your case, _lnurlp-YourUsername.hbs)

{
   "callback":"https://livingroomofsatoshi.com/api/v1/lnurl/payreq/XXXXX",
   "maxSendable":100000000000,
   "minSendable":1000,
   "metadata":"[[\"text/plain\",\"Pay to Wallet of Satoshi user: burlyring39\"],[\"text/identifier\",\"YourUsername@walletofsatoshi.com\"]]",
   "commentAllowed":32,
   "tag":"payRequest",
   "allowsNostr":true,
   "nostrPubkey":"YourNPUBkey"
}

After doing that, you almost finished, you just have to restart your Ghost blog.
As I use Ghost from docker container, I just had to restart the container.

To verify if everything is working, you have to go in the routes URL created earlier:

https://YourDomain.tld/.well-known/nostr.json

and

https://YourDomain.tld/.well-known/lnurlp/YourUsername

Both URL should display JSON files from .hbs created ealier.

If it's the case, you can add your NIP05 and LNURL into your Nostr profile client and you should be able to see a valid tick from your domain and to be zapped on your LNURL (sending zaps to your WoS or Alby backend wallet).

Voilààààà

See you soon in another Fractalized story!