เรามาลองติดตั้ง Nostr-relay-nestjs กันดีกว่า
เป็นเจ้าของรีเลย์ไม่ได้ยากอย่างที่คิดลองทำตามได้เลย
Relay ตัวนี้มีให้ตั้งค่ากรอง pow และ wot ด้วย หรือใครจะใช้เป็น Private relay ก็ทำได้เช่นกัน
วิธีติดตั้ง nostr-relay-nestjs มี 2 วิธี
ติดตั้งแบบลงเครื่องโดยตรง
ก่อนจะลง nostr-relay-nestjs ควรติดตั้ง Nodejs, pm2 และ postgresql
sudo apt update
ติดตั้ง nodejs
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
ติดตั้ง npm
sudo apt install npm
ติดตั้ง pm2
sudo npm install pm2 -g
ติดตั้ง postgresql สร้าง docker-compose.yml
version: '3.8'
services:
postgres:
image: postgres:latest
container_name: postgres
environment:
POSTGRES_DB: [db_name]
POSTGRES_USER: [user]
POSTGRES_PASSWORD: [password]
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- "5432:5432"
restart: unless-stopped
pgadmin:
image: dpage/pgadmin4:latest
container_name: pgadmin
environment:
PGADMIN_DEFAULT_EMAIL: [E-mail]
PGADMIN_DEFAULT_PASSWORD: [password]
ports:
- "5050:80"
depends_on:
- postgres
restart: unless-stopped
volumes:
postgres_data:
docker compose up -d
เรามาเริ่มลง nostr-relay-nestjs กันเถอะ
git clone https://github.com/CodyTseng/nostr-relay-nestjs.git
cd nostr-relay-nestjs
npm install
cp example.env .env
แก้ไข้ไฟล์ .env
DATABASE_URL=postgresql://[username]:[password]@[host]:[port]/[db_name]
.
.
RELAY_NAME=nostr-relay-nestjs
RELAY_DESCRIPTION=A Nostr relay with a clear architecture and high test coverage
RELAY_PUBKEY=[your_pubkey_hex]
สร้างรูปแบบ nostr event การเก็บข้อมูลใน Postgresql
npm run migration:run
Deployg ขึ้น pm2
pm2 start ./dist/src/main.js
ติดตั้งโดยใช้ Docker
อยากลืมติดตั้ง postgresql ก่อน
./scripts/build.sh
แก้ไข้ไฟล์ .env
DATABASE_URL=postgresql://[username]:[password]@[host]:[port]/[db_name]
.
.
RELAY_NAME=nostr-relay-nestjs
RELAY_DESCRIPTION=A Nostr relay with a clear architecture and high test coverage
RELAY_PUBKEY=[your_pubkey_hex]
./scripts/run.sh
เช็คว่ารีเลย์ถูกรันขึ้นยัง
curl localhost:3000
ถ้าทำงานผลลัพธ์ที่ได้
Please use a Nostr client to connect. Powered by nostr-relay-nestjs. version: 2.2.0 (undefined)
ตั้งค่า proxy ใน nginx
server{
server_name relay.yourdomain.com;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
หรือใช้ CloudFlare tunnel
ไปลองทำตามกันได้เลือกวิธีที่ตัวเองถนัดได้เลย แล้วเจอกันใหม่ครั้งหน้า จะเป็นเรื่องอะไรรอติดตามกัน
#Siamstr #Nostr
No comments yet.