Setting up Caddy Server for NIP-05 Verification


In the last post Adding Nostr NIP-05 Verification to Your Blog (Jekyll) I went over the steps for adding NIP-05 verification to your Jekyll blog. See the actual NIP-05 document here. Since then I've updated my setup to fix this common error you may have seen:


The issue here is that CORS wasn't set up correctly. You can learn more about CORS if you're interested but for those of you that just want to get it working I'm going to show you what I had to do in my Caddyfile:

(cors) {
  @cors_preflight method OPTIONS
  @cors header Origin {args.0}

  handle @cors_preflight {
    header Access-Control-Allow-Origin "*"
    header Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE"
    header Access-Control-Allow-Headers "Content-Type"
    header Access-Control-Max-Age "3600"
    respond "" 204

  handle @cors {
    header Access-Control-Allow-Origin "{args.0}"
    header Access-Control-Expose-Headers "Link"
} {
    import logging
    import cors *
    root * /home/azureuser/klabo-blog/_site/
    encode gzip
} {
    import logging
    route /.well-known/nostr.json {
	    rewrite * /nostrnip5/api/v1/domain/bHkhhSQdNE7ntZuYEPBVuL/nostr.json
	    reverse_proxy localhost:8000

I used a snippet to add support for CORS to the places I needed it. You'll notice I have two places I've set up NIP-05 verfication. My personal blog, and I have it set up on LNBits so others can set up theirs on the domain. If you want a verification you can get one here for 999 sats 🤙


Thats about it. Let me know if you run into any issues and good luck! Find me on nostr here: npub19a86gzxctwtz68l8zld2u9y2fjvyyj4juyx8m5geylssrmfj27eqs22ckt

Leave a tip