封闭脑袋

零落残魂何处断

搭建一个简单的NOSTR中继器

使用项目:nostr relay 一个python写的程序

  1. 使用pip安装:pip install nostr-relay
  2. 新建一个目录mkdir /opt/nostr,并进入目录 cd /opt/nostr
  3. 创建一个配置文件,参考官方默认配置 ,我的配置如下,修改了一点DEBUG: false ​ relay_name: python relay relay_description: relay written in python sysop_pubkey: sysop_contact: ​ storage: sqlalchemy.url: sqlite+aiosqlite:///nostr.sqlite3  # the number of concurrent REQ queries sent to the db num_concurrent_reqs: 10  # the number of concurrent event saves. (sqlite can only support 1 writer at a time) num_concurrent_adds: 2 validators:   - nostr_relay.validators.is_not_too_large   - nostr_relay.validators.is_signed   - nostr_relay.validators.is_recent   - nostr_relay.validators.is_not_hellthread ​ verification:  # options are disabled, passive, enabled nip05_verification: disabled expiration: 86400 * 30 update_frequency: 3600  #blacklist:  # - badhost.biz  #whitelist:  # - goodhost.com ​ ​ gunicorn: bind: 127.0.0.1:6969 workers: 1 loglevel: info reload: false ​ ​ purple: host: 127.0.0.1 port: 6969 workers: 1 disable_compression: true ​ ​ # see docs/authentication.md authentication: enabled: false relay_urls:   - ws://localhost:6969   - ws://127.0.0.1:6969    # 可以换成 ws://公网IP:6969   - wss://yourdomain.name actions:   save: a   query: a ​ # number of seconds to allow between client messages message_timeout: 1800 ​ # number of open subscriptions per connection subscription_limit: 32 ​ # set this to a private key used for internal control events # service_privatekey: 9627da965699a2a3048f97b77df5047e8cd0d11daca75e7687d0b28b65416a3c ​ # set this to limit the number of events returned per REQ max_limit: 6000 ​ # set this to the maximum number of "p" tags in an event hellthread_limit: 100
  1. 使用你喜欢的反向代理工具,配合域名使用。
  2. 使用systemd管理
    1. 创建service文件 vim /etc/systemd/system/nostr-relay.service
    2. 内容为[Unit] Description=Nostr Relay Service After=network.target ​ [Service] Type=simple User=root WorkingDirectory=/opt/nostr ExecStart=/usr/local/bin/nostr-relay -c /opt/nostr/config.yaml serve Restart=always RestartSec=5 StandardOutput=append:/opt/nostr/nostr-relay.log StandardError=append:/opt/nostr/nostr-relay-error.log ​ [Install] WantedBy=multi-user.target
    3. 保存并退出。
    4. 重载systemd服务 systemctl daemon-reload
    5. 启动并查看运行情况systemctl start nostr-relay systemctl status nostr-relay
    6. 设置开机自启 systemctl enable nostr-relay

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注