Skip to content

Commit e95d449

Browse files
committed
feat: add local dev configuration
Includes a reverse-proxy and locally-trusted TLS certs via mkcert, and uses a hostname that already points to 127.0.0.1 without having to modify the hosts file
1 parent 1073ef2 commit e95d449

File tree

6 files changed

+169
-1
lines changed

6 files changed

+169
-1
lines changed

.nostr.local/certs/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

.nostr.local/settings.json

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
{
2+
"info": {
3+
"relay_url": "wss://nostream.localtest.me",
4+
"name": "nostream.localtest.me",
5+
"description": "A nostr relay written in TypeScript.",
6+
"pubkey": "replace-with-your-pubkey",
7+
"contact": "[email protected]"
8+
},
9+
"network": {
10+
"max_payload_size": 131072,
11+
"remote_ip_header": "x-forwarded-for"
12+
},
13+
"workers": {
14+
"count": 0
15+
},
16+
"limits": {
17+
"event": {
18+
"eventId": {
19+
"minLeadingZeroBits": 0
20+
},
21+
"kind": {
22+
"whitelist": [],
23+
"blacklist": []
24+
},
25+
"pubkey": {
26+
"minLeadingZeroBits": 0,
27+
"whitelist": [],
28+
"blacklist": []
29+
},
30+
"createdAt": {
31+
"maxPositiveDelta": 900,
32+
"maxNegativeDelta": 0
33+
},
34+
"content": {
35+
"maxLength": 1048576
36+
},
37+
"rateLimits": [
38+
{
39+
"kinds": [0, 3, 40, 41],
40+
"period": 60000,
41+
"rate": 6
42+
},
43+
{
44+
"kinds": [1, 2, 4, 42],
45+
"period": 60000,
46+
"rate": 12
47+
},
48+
{
49+
"kinds": [1, 2, 4, 42],
50+
"period": 3600000,
51+
"rate": 360
52+
},
53+
{
54+
"kinds": [[5, 7], [43, 49]],
55+
"period": 60000,
56+
"rate": 30
57+
},
58+
{
59+
"kinds": [[10000, 19999], [30000, 39999]],
60+
"period": 60000,
61+
"rate": 24
62+
},
63+
{
64+
"kinds": [[20000, 29999]],
65+
"period": 60000,
66+
"rate": 60
67+
},
68+
{
69+
"period": 3600000,
70+
"rate": 720
71+
},
72+
{
73+
"period": 86400000,
74+
"rate": 2880
75+
}
76+
],
77+
"whitelists": {
78+
"pubkeys": [],
79+
"ipAddresses": [
80+
"::1",
81+
"::ffff:10.10.10.1"
82+
]
83+
}
84+
},
85+
"client": {
86+
"subscription": {
87+
"maxSubscriptions": 10,
88+
"maxFilters": 10
89+
}
90+
},
91+
"message": {
92+
"rateLimits": [
93+
{
94+
"period": 60000,
95+
"rate": 120
96+
},
97+
{
98+
"period": 3600000,
99+
"rate": 3600
100+
},
101+
{
102+
"period": 86400000,
103+
"rate": 86400
104+
}
105+
],
106+
"ipWhitelist": [
107+
"::1",
108+
"::ffff:10.10.10.1"
109+
]
110+
}
111+
}
112+
}

Caddyfile.local

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
auto_https disable_certs
3+
}
4+
5+
nostream.localtest.me {
6+
tls /root/certs/nostream.localtest.me.pem /root/certs/nostream.localtest.me-key.pem
7+
8+
reverse_proxy nostr-ts-relay:8008
9+
}

docker-compose.local.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
services:
2+
relay:
3+
volumes:
4+
- ${PWD}/.nostr.local:/home/node/
5+
caddy:
6+
image: caddy:2.6.2-alpine
7+
container_name: caddy
8+
ports:
9+
- 80:80
10+
- 443:443
11+
volumes:
12+
- ${PWD}/Caddyfile.local:/etc/caddy/Caddyfile
13+
- ${PWD}/.nostr.local/certs:/root/certs/
14+
- caddydata:/data
15+
- caddyconfig:/config
16+
restart: unless-stopped
17+
networks:
18+
default:
19+
ipv4_address: 10.10.10.5
20+
21+
volumes:
22+
caddyconfig:
23+
caddydata:

scripts/start_local

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
set -e
3+
4+
PROJECT_ROOT="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))/.."
5+
DOCKER_COMPOSE_FILE="${PROJECT_ROOT}/docker-compose.yml"
6+
DOCKER_COMPOSE_LOCAL_FILE="${PROJECT_ROOT}/docker-compose.local.yml"
7+
8+
if ! type "mkcert" &> /dev/null; then
9+
echo "Could not find mkcert, which is required for generating locally-trusted TLS certificates. Follow the installation instructions at https://github.com/FiloSottile/mkcert, then run this script again."
10+
exit 1
11+
fi
12+
13+
mkcert -install
14+
mkcert \
15+
-cert-file ${PROJECT_ROOT}/.nostr.local/certs/nostream.localtest.me.pem \
16+
-key-file ${PROJECT_ROOT}/.nostr.local/certs/nostream.localtest.me-key.pem \
17+
nostream.localtest.me
18+
19+
docker compose \
20+
-f $DOCKER_COMPOSE_FILE \
21+
-f $DOCKER_COMPOSE_LOCAL_FILE \
22+
up --build --remove-orphans $@

settings.sample.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"info": {
33
"relay_url": "wss://nostream.your-domain.com",
44
"name": "nostream.your-domain.com",
5-
"description": "A nostr relay written in Typescript.",
5+
"description": "A nostr relay written in TypeScript.",
66
"pubkey": "replace-with-your-pubkey",
77
"contact": "[email protected]"
88
},

0 commit comments

Comments
 (0)