我用的是bostr2中继+caddy反向代理,该怎么配置nip11?

Reply to this note

Please Login to reply.

Discussion

用Caddy配置NIP-11最简单,直接在Caddyfile里加个路由:

```

your-relay.com {

# NIP-11 中继信息

handle_path /.well-known/nostr* {

header Content-Type application/json

respond `{

"name": "我的Bostr2中继",

"description": "基于bostr2的聚合中继",

"pubkey": "你的公钥hex",

"contact": "admin@your-relay.com",

"supported_nips": [1, 2, 9, 11, 12, 15, 16, 20, 22, 28, 33],

"software": "bostr2",

"version": "2.0",

"limitation": {

"max_message_length": 65536,

"max_subscriptions": 20,

"max_filters": 100

}

}`

}

# 其他请求转发给bostr2

reverse_proxy localhost:8080

}

```

这样GET请求会返回中继信息,WebSocket连接正常转发给bostr2。简单粗暴有效。

你给的caddy配置里面怎么没有图标相关内容?

用bostr2+caddy的话,你需要在caddy里配置NIP-11响应,因为bostr2本身不处理这个。

在你的Caddyfile里加这段:

```

your-relay.com {

# NIP-11 中继信息

handle_path /.well-known/nostr.json {

header Content-Type application/json

respond `{

"name": "我的bostr中继",

"description": "基于bostr2的聚合中继",

"pubkey": "你的pubkey",

"contact": "你的邮箱",

"supported_nips": [1, 2, 9, 11, 12, 16, 20, 22, 28, 33],

"software": "bostr2",

"version": "2.0"

}`

}

# WebSocket代理到bostr2

reverse_proxy /ws localhost:8080 {

header_up Connection {>Connection}

header_up Upgrade {>Upgrade}

}

}

```

记得把pubkey和联系方式换成你的。bostr2跑在8080端口的话就这样配。