-
@ dhalsim
2025-04-20 21:09:09Prerequisites
- Install Citrine on your Android device:
- Visit https://github.com/greenart7c3/Citrine/releases
- Download the latest release using:
- zap.store
- Obtainium
- F-Droid
- Or download the APK directly
-
Note: You may need to enable "Install from Unknown Sources" in your Android settings
-
Domain Requirements:
- If you don't have a domain, purchase one
- If you have a domain not on Cloudflare, consider transferring it to Cloudflare for free SSL certificates and cloudflared support
Setting Up Citrine
- Open the Citrine app
- Start the server
- You'll see it running on
ws://127.0.0.1:4869
(local network only) - Go to settings and paste your npub into "Accept events signed by" inbox and press + button. This would prevent others from publishing events into your personal relay.
Installing Required Tools
- Install Termux from Google Play Store
- Open Termux and run:
bash pkg update && pkg install wget wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-arm64.deb dpkg -i cloudflared-linux-arm64.deb
Cloudflare Authentication
- Run the authentication command:
bash cloudflared tunnel login
- Follow the instructions:
- Copy the provided URL to your browser
- Log in to your Cloudflare account
- If the URL expires, copy it again after logging in
Creating the Tunnel
- Create a new tunnel:
bash cloudflared tunnel create <TUNNEL_NAME>
- Choose any name you prefer for your tunnel
-
Copy the tunnel ID after creating the tunnel
-
Create and configure the tunnel config:
bash touch ~/.cloudflared/config.yml nano ~/.cloudflared/config.yml
-
Add this configuration (replace placeholders): ```yaml tunnel:
credentials-file: /data/data/com.termux/files/home/.cloudflared/ .json ingress: - hostname: nostr.yourdomain.com service: ws://localhost:4869
- service: http_status:404 ```
- Note: In nano editor:
CTRL+O
and Enter to saveCTRL+X
to exit
-
Note: Check the credentials file path in the logs
-
Validate your configuration:
bash cloudflared tunnel validate
-
Start the tunnel:
bash cloudflared tunnel run my-relay
Preventing Android from Killing the Tunnel
Run these commands to maintain tunnel stability:
bash date && apt install termux-tools && termux-setup-storage && termux-wake-lock echo "nameserver 1.1.1.1" > $PREFIX/etc/resolv.conf
Tip: You can open multiple Termux sessions by swiping from the left edge of the screen while keeping your tunnel process running.
Updating Your Outbox Model Relays
Once your relay is running and accessible via your domain, you'll want to update your relay list in the Nostr network. This ensures other clients know about your relay and can connect to it.
- Create a kind 10002 event with your relay list:
- Include your new relay with write permissions
- Include other relays you want to read from
- Example format:
json { "kind": 10002, "tags": [ ["r", "wss://your-relay-domain.com", "write"], ["r", "wss://eden.nostr.land/", "read"], ["r", "wss://nos.lol/", "read"], ["r", "wss://nostr.bitcoiner.social/", "read"], ["r", "wss://nostr.mom/", "read"], ["r", "wss://relay.primal.net/", "read"], ["r", "wss://nostr.wine/", "read"], ["r", "wss://relay.damus.io/", "read"], ["r", "wss://relay.nostr.band/", "read"], ["r", "wss://relay.snort.social/", "read"] ], "content": "" }
Save it to a file called
event.json
Note: Add or remove any relays you want. Check your existing 10002 relays from the following URL: https://nostr.band/?q=by%3Anpub1dejts0qlva8mqzjlrxqkc2tmvs2t7elszky5upxaf3jha9qs9m5q605uc4+++kind%3A10002, Change the
npub1xxx
part with your own npub, and VIEW JSON from menu to see the raw event.- Sign and publish the event:
- Use a Nostr client that supports kind 10002 events
-
Or use the
nak
(https://github.com/fiatjaf/nak) command-line tool:bash cat event.json | nak event --sec <your-private-key> wss://relay1.com wss://relay2.com
-
Verify the event was published:
- Check if your relay list is visible on other relays
-
Use the
nak
tool to fetch your kind 10002 events:bash nak req -k 10002 -a <your-pubkey> wss://relay1.com wss://relay2.com
-
Testing your relay:
- Try connecting to your relay using different Nostr clients
- Verify you can both read from and write to your relay
- Check if events are being properly stored and retrieved
- Tip: Use multiple clients to test different aspects of your relay
Note: If anyone in the community has a more efficient method of doing things like updating outbox relays, please share your insights in the comments. Your expertise would be greatly appreciated!