Hello Stackers!
Do you want to maintain full control over your NIP-05 identity and use your own domain? If so, setting up a self-hosted NIP-05 ID on Nostr is pretty easy. I'll walk you through the simple steps to set up a self-hosted NIP-05 ID on Nostr using your own domain and hosting.
Before we get started, make sure you have your own domain and hosting. If you don't have one, you can purchase them from any hosting provider of your choice. Also, make sure you have your Nostr Pubkey in hexadecimal format. You can convert it using a tool like https://astral.ninja/devTools
Step 1: The first step is to enter your hosting or web server using Filezilla, an FTP client that allows you to transfer files from your computer to your hosting server. Once you're logged in, navigate to the public_html folder and create a new folder called ".well-known."
Step 2: Now that you have created the ".well-known" folder, you need to create a file called "nostr.json" inside it. Open a text editor on your computer and paste the following code:
{ "names": { "YOUR_NAME": "YOUR_PUBKEY_IN_HEX_FORMAT" }, "relays": { "YOUR_PUBKEY_IN_HEX_FORMAT": [ "wss://nostr.eden.land", "wss://nostr.relay.damus.io", "wss://relay.snort.social", "wss://relay.orangepill.dev" ] } }
Replace "YOUR_NAME" with any name you want, and "YOUR_PUBKEY_IN_HEX_FORMAT" with your Nostr Pubkey in Hex format. You can find your pubkey in your Nostr account settings. The relay section is optional, but it allows clients to know which relays they are likely to find you on. Therefore, customize it with the relays added to your account.
Step 3: Now, create a new file in the public_html folder and name it ".htaccess". Open the file and paste the following code: <IfModule mod_headers.c> Header set Access-Control-Allow-Origin "*" </IfModule>
This code allows your NIP-05 ID to be accessible by any domain.
Step 4: Finally, go to your Nostr client and fulfill the NIP-05 ID with your name you previously added in the nostr.json file + your domain. For example, if your name is "example" and your domain is "domain.com," your NIP-05 ID would be "example@domain.com".
Congratulations, you've successfully set up a self-hosted NIP-05 ID on Nostr using your own domain and hosting! Enjoy the privacy and control that comes with having your own identity system.
Thank you for this.
I've done everything you said, except 1 thing.. "create a new file in the public_html folder and name it ".htaccess"."
The reason being, this file already exists on my website, so I added the code snippet the end of the existing file.
The issue I'm having is that it appears to show I'm verified on Damus, but not on snort or primal. Is this just a propagation thing where I have to wait?
reply
By step 3, those instructions apply to when you are running a Apache webserver.
When you are using Nginx as your webserver, you can add this snippet to your server configuration file for setting the CORS on any files in the .well-known directory:
location /.well-known { if ($request_method = 'GET') { add_header 'Access-Control-Allow-Origin' '*'; } }
reply
Thank you for the additional information!
Also, adding after the Step 3., a good practice is checking if the domain is actually accessible with a tool like https://cors-test.codehappy.dev/
reply
I can't seem to get it to work the only thing I did different was I used NameCheap for hosting