A purely Python, easy to deploy nostr relay using asyncio
& websockets
to serve Nostr clients
A 100% containerized Python relay backed by a Postgres database, behind a NGINX reverse proxy. This has been tested on Nostrudel, Iris.to and [Snort.social](https://Snort.social, Damus.io) clients and works for the NIPS listed below.
Numerous branches in development, trying to improve performance, reliability and ease of use.
- Ubuntu 22.04 server (Will likely work on other versions but this is all that has been tested)
- Both
arm64
andamd64
supported
- Both
- At least 2 GB of available RAM
- Your own domain
To setup this program, you need to update the variables in the nostpy/docker_stuff/.env
, for example:
PGDATABASE_WRITE=<POSTGRES_WRITE_DATABASE>
PGUSER_WRITE=<POSTGRES_WRITE_USER>
PGPASSWORD_WRITE=<POSTGRES_WRITE_PASSWORD>
PGPORT_WRITE=<POSTGRES_WRITE_PORT>
PGHOST_WRITE=<POSTGRES_WRITE_HOST>
PGDATABASE_READ=<POSTGRES_READ_DATABASE>
PGUSER_READ=<POSTGRES_READ_USER>
PGPASSWORD_READ=<POSTGRES_READ_PASSWORD>
PGPORT_READ=<POSTGRES_READ_PORT>
PGHOST_READ=<POSTGRES_READ_HOST>
DD_ENV=<DATADOG_ENV_TAG>
EVENT_HANDLER_PORT=8009
EVENT_HANDLER_SVC=172.28.0.3 # hostname or IP for event handler service
WS_PORT=8008 #Websocket handler port
REDIS_HOST=redis
REDIS_PORT=6379
DD_API_KEY=<DATADOG_API_KEY_> (If using Datadog exporter for OTel collector)
DOMAIN=<YOUR_DOMAIN_NAME>
HEX_PUBKEY=<RELAY_ADMIN_HEX_PUBKEY>
ADMIN_HEX_PUBKEY=<THE_PUBKEY_FOR _REMOTE_RELAY_ADMINISTRATION> #This can be differnt than your pubkey for nip 11
CONTACT=<RELAY_ADMIN_EMAIL>
ENV_FILE_PATH=./docker_stuff/.env
NGINX_FILE_PATH=/etc/nginx/sites-available/default
VERSION=v1.0.0
Aside from adding the environmental variables, all you need to do is run the menu.py
script to load the menu. Once you select the Execute server setup script
option, the script will install all dependencies, create all service containers locally, including setting up your NGINX reverse proxy server, requesting TLS certificate. From there you are ready to start relaying notes!
To get started run the command below from the main repo direcotory to bring up the NostPy menu:
python3 menu.py
This will bring up the menu below and you can control the program from there!
Usage notes
- Option 1
Execute server setup script
needs to be run to create therelay_service
user and set proper file permissions - After creating the
.env
that file is meant to stay encrypted(encrypted suringExecute server script
), option2Start Nostpy relay
will not run unless the file is encypted- You can encrypt/decrypt the file with option 5
This compose stack comes with a preconfigured OpenTelemety collector container and some custom instrumentation. the existing configuration collects system metrics about the host and docker containers as well as distributed tracing between the services.
Will be adding log support soon, giving you full visibility into the health of your relay.
You can use nostpy-gui as a remote relay admin client to manage the following using notes:
- Ban
pubkey
from posting events - Ban
kinds
from being posted - Delete all stored notes from a given
pubkey
This is relay is actively worked on, it's is only a proof of concept right now. Will contine to add features, bug fixes and documentation weekly, check back for updates.
unchecked NIPS are on the roadmap
- NIP-01: Basic protocol flow description
- NIP-02: Contact list and petnames
- NIP-04: Encrypted Direct Message
- NIP-09: Event deletion
- NIP-11: Relay information document
- [] NIP-11a: Relay Information Document Extensions
- [] NIP-13: Proof of Work
- NIP-15: End of Stored Events Notice
- NIP-16: Event Treatment
- NIP-25: Reactions
- NIP-50: Search Capability
- NIP-99: Classified Listings
If you would like to contribute feel free to fork and put in a PR! Also please report any bugs in the issues section of this repo.