免费翻墙freefq.com

  移动端← | →PC电脑端
您当前的位置:首页 > 网络翻墙技巧

搭建一个nostr中继服务

时间:2023-11-14  来源:  作者: 0 条评论

nostr 是一个相当简单的开放协议,可以在全球范围内搭建一个有趣的社交网络。因为协议本身很简单,所以大部分的加密、签名工作在客户端完成,而中继服务器 Relay 所做的事情只是接收事件消息,根据客户端订阅要求返回消息。Pko免费翻墙网

目前 relay 的实现也很多,比如 nostream 的搭建就很方便,只要安装好 docker,设置好域名,直接运行就可以啦。Pko免费翻墙网

以下记录一下 Relay 的搭建过程。Pko免费翻墙网

1. 安装基础软件

首先分配一台安装 Ubuntu Server 20.04 LTS Ubuntu Server 20.04 LTS 操作系统的虚拟机,默认规格就够了。Pko免费翻墙网

首先,更新软件包列表。提示 30 个软件包需要升级,暂时先不管。Pko免费翻墙网

kimim@nostr:~$ sudo apt update

# update package list from mirrors
Fetched 25.5 MB in 4s (6240 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
30 packages can be upgraded. Run 'apt list --upgradable' to see them.

然后,安装以下软件包,用来运行编译 nostream,配置 relay 的证书。Pko免费翻墙网

kimim@nostr:~$ sudo apt install nodejs npm nginx certbot python3-certbot-nginx

# list of packages need to be installed
0 upgraded, 410 newly installed, 0 to remove and 30 not upgraded.
Need to get 168 MB of archives.
After this operation, 669 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
# installation in progress

2. 安装 docker

接下来,安装 docker,因为根据 nostream 官网要求,需要安装官方的 docker。就是按照 https://docs.docker.com/engine/install/ubuntu/ 安装 docker。Pko免费翻墙网

首先,删除已经安装的 docker(如果有,我的这台机器刚初始化,所以没有安装 docker)。Pko免费翻墙网

kimim@nostr:~$ sudo apt-get remove docker.io
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package 'docker.io' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 30 not upgraded.

然后,安装 docker 需要的证书组件。Pko免费翻墙网

kimim@nostr:~$ sudo apt-get install ca-certificates curl gnupg lsb-release
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
lsb-release is already the newest version (11.1.0ubuntu4).
lsb-release set to manually installed.
ca-certificates is already the newest version (20211016ubuntu0.22.04.1).
ca-certificates set to manually installed.
curl is already the newest version (7.81.0-1ubuntu1.7).
curl set to manually installed.
gnupg is already the newest version (2.2.27-3ubuntu2.1).
gnupg set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 30 not upgraded.

接着,添加 docker 官方 GPG 证书。Pko免费翻墙网

kimim@nostr:~$ sudo mkdir -p /etc/apt/keyrings
kimim@nostr:~$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

添加 docker 官方源:Pko免费翻墙网

kimim@nostr:~$ echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

再次更新软件包:Pko免费翻墙网

kimim@nostr:~$ sudo apt-get update
Get:1 https://download.docker.com/linux/ubuntu jammy InRelease [48.9 kB]
Get:2 https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages [12.7 kB]
Fetched 61.6 kB in 1s (105 kB/s)
Reading package lists... Done

安装 docker 以及 cli,compose 插件。Pko免费翻墙网

kimim@nostr:~$ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin

# list of packages need to be installed
0 upgraded, 11 newly installed, 0 to remove and 30 not upgraded.
Need to get 111 MB of archives.
After this operation, 397 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

# installation in progress

把当前用户添加到 docker 权限组:Pko免费翻墙网

kimim@nostr:~$ sudo usermod -a -G docker kimim
kimim@nostr:~$ newgrp docker

测试一下 docker 是否正常工作:Pko免费翻墙网

kimim@nostr:~$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:aa0cc8055b82dc2509bed2e19b275c8f463506616377219d9642221ab53cf9fe
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

3. 配置服务器证书

修改 nginx 的配置文件。请根据自己的服务器域名修改 server_name 字段。Pko免费翻墙网

kimim@nostr:~$ sudo rm -rf /etc/nginx/sites-available/default
kimim@nostr:~$ sudo vi /etc/nginx/sites-available/default
# 添加以下内容
kimim@nostr:~$ cat /etc/nginx/sites-available/default
server{
    server_name nostr.kimi.im;
    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_pass http://127.0.0.1:8008;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

重启 nginx,使配置生效。Pko免费翻墙网

kimim@nostr:~$ sudo service nginx restart

添加 A 域名记录,比如:Pko免费翻墙网

TYPE    HOST            ANSWER          TTL
A       nostr.kimi.im   192.30.252.153  300

等一两分钟,等域名记录生效,再用 certbox 配置服务器证书:Pko免费翻墙网

kimim@nostr:~$ sudo certbot --nginx -d nostr.kimi.im
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices)
 (Enter 'c' to cancel): kimim@kimi.im

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.3-September-21-2022.pdf. You must
agree in order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/nostr.kimi.im/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/nostr.kimi.im/privkey.pem
This certificate expires on 2023-05-05.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.

Deploying certificate
Successfully deployed certificate for nostr.kimi.im to /etc/nginx/sites-enabled/default
Congratulations! You have successfully enabled HTTPS on https://nostr.kimi.im

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
 * Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
 * Donating to EFF:                    https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

4. 运行 nostream

获取 nostream 代码:Pko免费翻墙网

kimim@nostr:~$ git clone https://github.com/Cameri/nostream.git
Cloning into 'nostream'...
remote: Enumerating objects: 3287, done.
remote: Counting objects: 100% (1228/1228), done.
remote: Compressing objects: 100% (415/415), done.
remote: Total 3287 (delta 889), reused 984 (delta 803), pack-reused 2059
Receiving objects: 100% (3287/3287), 1.05 MiB | 7.90 MiB/s, done.
Resolving deltas: 100% (2036/2036), done.

用 docker 运行 nostream,大概用了两分钟,就看到一个漂亮的 NOSTREAM logo 了。Pko免费翻墙网

kimim@nostr:~$ cd nostream/
kimim@nostr:~/nostream$ npm run docker:compose:start
> nostream@1.21.0 docker:compose:start
> ./scripts/start

[+] Running 25/25
# ...
[+] Building 128.2s (16/16) FINISHED
# ...
[+] Running 6/5
# ...
Attaching to nostream, nostream-cache, nostream-db, nostream-migrate
# ...
nostream-db       | CREATE DATABASE
# ...
nostream          |
nostream          |  ███▄    █  ▒█████    ██████ ▄▄▄█████▓ ██▀███  ▓█████ ▄▄▄       ███▄ ▄███▓
nostream          |  ██ ▀█   █ ▒██▒  ██▒▒██    ▒ ▓  ██▒ ▓▒▓██ ▒ ██▒▓█   ▀▒████▄    ▓██▒▀█▀ ██▒
nostream          | ▓██  ▀█ ██▒▒██░  ██▒░ ▓██▄   ▒ ▓██░ ▒░▓██ ░▄█ ▒▒███  ▒██  ▀█▄  ▓██    ▓██░
nostream          | ▓██▒  ▐▌██▒▒██   ██░  ▒   ██▒░ ▓██▓ ░ ▒██▀▀█▄  ▒▓█  ▄░██▄▄▄▄██ ▒██    ▒██
nostream          | ▒██░   ▓██░░ ████▓▒░▒██████▒▒  ▒██▒ ░ ░██▓ ▒██▒░▒████▒▓█   ▓██▒▒██▒   ░██▒
nostream          | ░ ▒░   ▒ ▒ ░ ▒░▒░▒░ ▒ ▒▓▒ ▒ ░  ▒ ░░   ░ ▒▓ ░▒▓░░░ ▒░ ░▒▒   ▓▒█░░ ▒░   ░  ░
nostream          | ░ ░░   ░ ▒░  ░ ▒ ▒░ ░ ░▒  ░ ░    ░      ░▒ ░ ▒░ ░ ░  ░ ▒   ▒▒ ░░  ░      ░
nostream          |    ░   ░ ░ ░ ░ ░ ▒  ░  ░  ░    ░        ░░   ░    ░    ░   ▒   ░      ░
nostream          |          ░     ░ ░        ░              ░        ░  ░     ░  ░       ░
nostream          |                                   v1.21.0
nostream          |           NIPs implemented: 1,2,4,9,11,12,15,16,20,22,26,28,33,40
nostream          |                            Pay-to-relay disabled
nostream          |                          Payments provider: zebedee
nostream          |                           2 client workers started
nostream          |                         1 maintenance worker started
nostream          |                         Tor hidden service: disabled

5. 用 noscl 测试 relay 是否正常工作

删除之前添加的 relay:Pko免费翻墙网

[kimim@virtualbox Desktop]$ ./noscl relay
wss://nos.lol: rw
[kimim@virtualbox Desktop]$ ./noscl relay remove wss://nos.lol
Removed relay wss://nos.lol.

添加刚刚搭建的 relay:Pko免费翻墙网

[kimim@virtualbox Desktop]$ ./noscl relay add wss://nostr.kimi.im
Added relay wss://nostr.kimi.im.

发送消息 Bonjour tout le monde:Pko免费翻墙网

[kimim@virtualbox Desktop]$ ./noscl publish "Bonjour tout le monde"
Sent event a170e3f3c4f8cfb79cacccf28d5f7d51a5e17b4e40c0984593a692b83f9cf43c to 'wss://nostr.kimi.im'.
Seen a170e3f3c4f8cfb79cacccf28d5f7d51a5e17b4e40c0984593a692b83f9cf43c on 'wss://nostr.kimi.im'.

在 Damus 一开始收不测试帐号发送的消息,需要在 Damus 客户端也添加同样的 relay。Pko免费翻墙网

然后,就能看到测试帐号发的:Bonjour tout le mondePko免费翻墙网
via https://kimi.im/2023-02-04-setup-nostr-relayPko免费翻墙网

 

返回→:首页 > 网络翻墙技巧

相关文章

  • 一个代驾司机之死
  • 国务委员秦刚的案子有了一个交代
  • 习近平亲信一个接着一个失踪
  • Arti1.1.8 发布:洋葱服务基础设施
  • 一个贫困县打破「县中魔咒」之后
  • 一台服务器上最多能创建多少个TCP连接?
  • 下一个严重过剩的专业可能是?
  • 怎样养育一个心理健康的孩子?
  • 一个中国00后的政治启蒙故事
  • 如果判断一个数字帐号来自中国大陆
  • 栏目更新

  • Linux系统翻墙方法大全
  • 使用Clash relay拯救被封VPS
  • 永久免费VPN,还不限流量,直接把付
  • 2024永久免费翻墙加速器app梯子
  • 2024超简单免费VPN:全新翻墙软件H
  • WhatsApp翻墙技巧
  • 如何生成GPT-4 arkose_token?
  • 2023年谷歌镜像更新
  • 不翻墙上github的方法
  • 惊曝光猫内置反诈插件
  • 搭建一个nostr中继服务
  • 人人都能看懂的旁路由入门指南
  • 旁路由的原理与配置一文通
  • 使用Yggdrasil进行远程访问
  • 谷歌将Outline开源项目代码提供给开
  • 家庭网络改造记录:旁路由
  • 信息茧房自救指南
  • 备用翻墙方案:eSIM
  • Warp: 一种安全的跨平台文件共享应
  • T-Mobile原生手机卡购买激活教程
  • 栏目热门

  • 解决OpenAI和ChatGPT的API无法访问
  • BT种子搜索网站和磁力链接搜索引擎
  • Hardening Android for Security A
  • 将你的树莓派打造成一个Tor中继节点
  • ShadowSocks影梭不完全指南
  • 全球免费DNS集合
  • Android Pie私人DNS简介及使用
  • TP-Link路由器内建VPN助翻墙
  • 免费拥有一个美国的手机号码
  • 通用的全站镜像反向代理zmirror
  • 墙外新闻

  • 宋楚瑜的嘴脸
  • 他们遭到「种族灭绝」?
  • 数字排毒如何进行?
  • 他们是否成了时代的牺牲品?
  • 童养媳如何成为世界健美冠军?
  • 破解自闭症迷思
  • 中美谈判取得什么 “重大进展”?
  • 中国恢复进口日本水产品!
  • 教皇名字背后的意涵
  • 中国军工央企高层人事大地震
  • 读者文摘

  • 喝硬水对身体健康是好是坏?
  • 特朗普将如何输掉与中国的贸易战?
  • 特朗普为什么会赢?
  • 韩国的“工蜂”经济及其对中国的启
  • 干什么可以预防老年痴呆?
  • 为什么瓶装水未必更健康?
  • 西红柿和番茄红素的保健作用
  • 花青素的保健作用
  • 贸易战中不可轻易误判对手已经撑不
  • 网络社交媒体颜色革命的回顾与前瞻
  • 欢迎评论:免登录,输入验证码即可匿名评论 共有0条评论
    用户名: 密码:
    验证码: 匿名发表
    搜索:
      移动端← | →PC电脑端

    免费翻墙网freefq.com

    关于本站 | 联系我们 | 免责声明 | 赞助本站 | 网站地图 | 浏览建议

    Powered by 免费翻墙网freefq.com  © 2014-2025 免费翻墙软件网——提供最全的免费翻墙软件

    管理员精中特别提醒:本网站域名、主机和管理员都在美国,且本站内容仅为非中国大陆网友服务。禁止中国大陆网友浏览本站!若中国大陆网友因错误操作打开本站网页,请立即关闭!中国大陆网友浏览本站存在法律风险,恳请立即关闭本站所有页面!对于您因浏览本站所遭遇的法律问题、安全问题和其他所有问题,本站均无法负责也概不负责。

    特别警告:本站推荐各种免费科学上网软件、app和方法,不建议各位网友购买收费账号或服务。若您因付费购买而遭遇骗局,没有得到想要的服务,请把苦水往自己肚子里咽,本站无法承担也概不承担任何责任!

    本站严正声明:各位翻墙的网友切勿将本站介绍的翻墙方法运用于违反当地法律法规的活动,本站对网友的遵纪守法行为表示支持,对网友的违法犯罪行为表示反对!

    网站管理员定居美国,因此本站所推荐的翻墙软件及翻墙方法都未经测试,发布仅供网友测试和参考,但你懂的——翻墙软件或方法随时有可能失效,因此本站信息具有极强时效性,想要更多有效免费翻墙方法敬请阅读本站最新信息,建议收藏本站!本站为纯粹技术网站,支持科学与民主,支持宗教信仰自由,反对恐怖主义、邪教、伪科学与专制,不支持或反对任何极端主义的政治观点或宗教信仰。有注明出处的信息均为转载文章,转载信息仅供参考,并不表明本站支持其观点或行为。未注明出处的信息为本站原创,转载时也请注明来自本站。

    鉴于各种免费翻墙软件甚至是收费翻墙软件可能存在的安全风险及个人隐私泄漏可能,本站提醒各位网友做好各方面的安全防护措施!本站无法对推荐的翻墙软件、应用或服务等进行全面而严格的安全测试,因此无法对其安全性做保证,无法对您因为安全问题或隐私泄漏等问题造成的任何损失承担任何责任!

    S. Grand Ave.,Suite 3910,Los Angeles,CA 90071

    知识共享许可协议
    本作品采用知识共享署名-非商业性使用 4.0 国际许可协议进行许可。

      SSL site seal - click to verify