在云服务器上搭建 Nostr 中继器
2023年8月24日 01:49
如何在云服务器上搭建 Nostr 中继器,并在 Nostr 客户端中连接使用。
我在这个文章 还未写完 的时候就 鸽 掉了 Nostr 的搭建!
强烈建议不要根据这个教程来搭建 Nostr 中继器!
你需要先知道:
- 我使用的云服务器的提供商为 DigitalOcean
- 我使用的云服务器的系统为 Ubuntu 22.04(LTS)x64
- 我使用的云服务器的配置为 1 个 CPU、1GB 内存,以及 25GB 固态
- 我使用的云服务器有 ipv6 地址和固定公共 IP 地址
- 你需要有一个域名
创建用户
创建一个不是 root 的用户:
adduser 用户名如果执行这个指令后系统要求你创建一个密码,那就不需要执行下面这个指令;反之,执行该命令给该用户设置密码:
passwd 用户名将该用户添加到 sudo 组中,从而授予其 sudoer 权限:
usermod -aG sudo 用户名从 root 切换到我们创建的用户:
su 用户名
安装 Docker
sudo apt updatesudo apt install nodejs npm nginx certbot python3-certbot-nginx# 下载 Docker 的 GPG 密钥sudo mkdir -p /etc/apt/keyringscurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg# 安装 Dockerecho "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"echo "sudo tee /etc/apt/sources.list.d/docker.list > /dev/null"sudo chmod a+r /etc/apt/keyrings/docker.gpgsudo apt updatesudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin下载 nostream
cd /home/用户名git clone https://github.com/Cameri/nostream.git配置 nginx
# 删除默认的 nginx 配置文件rm -rf /etc/nginx/sites-available/default# 通过 nano 进入新的配置文件sudo nano /etc/nginx/sites-available/default将以下内容复制粘贴到这个新的配置文件:
server{ server_name 子域名.域名.后缀; 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:
sudo service nginx restart设置域名的 DNS
在你的域名 DNS 设置中,你需要添加两个记录:

启动 Nostr 中继器
sudo certbot --nginx -d 子域名.域名.后缀cd ~/nostream# 开启 TMUX 会话# 用于分离和维护进程运行tmux# 启动中继器sudo chmod 666 /var/run/docker.socknpm run docker:compose:start