Add public nostr submission relay and approved-content sync #705

Merged
raucao merged 8 commits from feature/nostr_submission_relay into master 2026-11-18 11:09:47 +00:00
22 changed files with 1205 additions and 1 deletions

No files matched your search

+215
View File
@@ -0,0 +1,215 @@
# Nostr submission relay (Chef)
Chef-side pieces of the public submission relay + image-recognition moderation
MVP ([`raucao/marco#97`](https://gitea.kosmos.org/raucao/marco/issues/97)). The
canonical plan/spec lives in the Marco repo, `doc/nostr/submission-relay-mvp/`.
This document is the Chef runbook: what the code deploys, how it was rolled out,
and how to roll it back. **The stack is deployed to production** — the relay is
live at `wss://submit.nostr.kosmos.org` and both promotion paths are enabled.
The deployment order below is kept as a record of the rollout and for rebuilding
the service elsewhere.
## What the Chef code adds
| Piece | Where | Recipe / role |
| --- | --- | --- |
| Public submission relay (strfry #2, `:7778`) | one node | `role[strfry_submission]` → `kosmos_strfry_submission::default` |
| Firewall for `:7778` | same node | `kosmos_strfry_submission::firewall` |
| `wss://submit.nostr.kosmos.org` vhost + cert | openresty proxy nodes | `kosmos_strfry_submission::nginx` (via `role[openresty_proxy]`) |
| Approved-event sync (staging `:7779` → production DB) | production relay node | `kosmos_strfry::approved_sync` (via `role[strfry]`) |
| Member bridge (`:7778` → production DB, LDAP-only) | production relay node | `kosmos_strfry::member_bridge` (via `role[strfry]`) |
| Node 24 LTS for the Node write policies | relay nodes | role-scoped `kosmos_nodejs.version` override |
Write policies from `kosmos/akkounts` `extras/strfry/` are fetched at converge
time:
* `submission-policy.mjs` — open write gates for the submission relay (Node).
* `sync-policy.mjs` — fail-closed policy for `strfry sync` (Node; see below).
* `ldap-only-policy.ts` — LDAP membership gate for the member bridge (Deno; see
below).
## Design notes / invariants
* **The submission relay is not `role[strfry].`** The openresty proxy builds its
production `_strfry` upstream from `role:strfry`; a submission node must never
be added to it. The new role also avoids `role[ldap_client]`, because the
submission relay is open to all authors and does not do LDAP.
* **The sync is the only non-member write path into production.** It runs
`strfry --config /etc/strfry-sync.conf sync <staging> --dir down`, one-way,
every 5 minutes. `strfry sync --dir down` runs the *local* write policy with
`sourceType="Sync"` and `sourceInfo=<remote relay URL>`
(`src/apps/mesh/cmd_sync.cpp`), so `sync-policy.mjs` can accept only that exact
source and reject everything else. `STAGING_RELAY_URL` is passed to the unit
and must byte-match the URL on the command line — both come from the single
`node["strfry"]["staging_relay_url"]` attribute.
* **The sync uses the production database** (`node["strfry"]["config"]["db"]`)
with a 100-year age floor (`rejectEventsOlderThanSeconds = 3153600000`) so
long-delayed approvals still land. Note that `0` does **not** disable this
check in strfry: strfry computes `earliest = now - rejectEventsOlderThanSeconds`,
so `0` makes `earliest == now` and rejects every event as "created_at too
early" *before the write policy runs*. A large bound is the way to turn it off.
* **The sync config sets `nofiles` explicitly.** strfry raises its `RLIMIT_NOFILE`
to `relay.nofiles` at startup and exits if that exceeds the process hard limit.
The compiled-in default (1000000) is above the systemd default here (524288),
so `strfry_sync.conf.erb` sets `nofiles = <production value or 524288>`. Without
it the sync fails to start with `Unable to set NOFILES limit to 1000000`.
* **The submission relay is reachable only from the openresty proxy nodes.**
The relay trusts nginx's `X-Real-IP` (`realIpHeader = "x-real-ip"`), so a
direct connection could forge that header and defeat the policy's per-IP token
bucket. `kosmos_strfry_submission::firewall` therefore allow-lists the ZT IPs
of the `role:openresty_proxy` nodes instead of all of `10.1.1.0/24` (the
per-author bucket is unaffected). Consequence: anything that talks to the
relay *directly* over ZeroTier must be added explicitly — in particular, if
the WS2 moderator is switched from `wss://submit.nostr.kosmos.org` to the
ZT-direct `ws://<relay>:7778`, add the nuc's address to the allow-list (or
route it through nginx). The member bridge uses loopback and is unaffected.
* **No `--filter` on the sync.** The worker only publishes approved events to
the staging relay; the policy is the gate.
* **The member bridge is a live `strfry router`, not a service.** A stream group
with `dir = "down"` subscribes to `ws://localhost:7778` and writes
member-authored events into the production LMDB; its `pluginDown` is
`ldap-only-policy.ts`, so membership is decided per event by LDAP and no member
list is maintained. The group's `filter` bounds the REQ (and therefore the LDAP
lookups) to the submission kinds. `dir = "down"` makes it strictly one-way: the
router never watches or forwards the local DB. `pluginDown`'s path contains no
spaces, so strfry watches its mtime and hot-reloads it without a restart. It
writes to the same LMDB as the relay (the same multi-process access pattern as
the approved sync).
* **Both promotion paths are enabled from `role[strfry_submission]`.** The
`strfry.approved_sync.enabled` and `strfry.member_bridge.enabled` switches are
set as role overrides, not in the production environment, so they travel with
this feature's roles. (The recipes themselves live in `role[strfry]`; the relay
node runs both roles.)
## Attributes
| Attribute | Default | Notes |
| --- | --- | --- |
| `strfry.staging_relay_url` | `ws://10.1.1.183:7779` | nuc ZeroTier IP + staging port |
| `strfry.approved_sync.enabled` | `false` | **no-op until enabled** (`true` in `role[strfry_submission]`) |
| `strfry.member_bridge.enabled` | `false` | **no-op until enabled** (`true` in `role[strfry_submission]`) |
| `strfry.member_bridge.subscribe_relay` | `ws://localhost:7778` | local submission relay |
| `strfry.member_bridge.plugin_cmd` | `/opt/strfry/ldap-only-policy.ts` | LDAP-only `pluginDown` |
| `strfry.member_bridge.kinds` | `[0, 3, 5, 360, 30360]` | router REQ kind filter |
| `strfry_submission.domain` | `submit.nostr.kosmos.org` | |
| `strfry_submission.port` | `7778` | |
| `strfry_submission.config.db_params.mapsize` | `4 GiB` | disk cap for the disposable DB |
## Regression checks
`site-cookbooks/kosmos_strfry/test/strfry_sync_conf_test.rb` renders
`strfry_sync.conf.erb` with the attribute shapes `approved_sync.rb` passes and
fails if the sync config's `rejectEventsOlderThanSeconds` is missing or `<= 0`
(the guard for the "0 rejects every event" trap above) or if `nofiles` is not
set to the expected value (strfry exits at startup when its `nofiles` exceeds
the systemd `LimitNOFILE`). It needs neither a Chef server nor a converge — only
the `chef` gem and stdlib ERB:
```
ruby site-cookbooks/kosmos_strfry/test/strfry_sync_conf_test.rb
```
`site-cookbooks/kosmos_strfry/test/member_bridge_conf_test.rb` renders
`member_bridge.conf.erb` with the attribute shapes `member_bridge.rb` passes and
fails if the stream group is not one-way (`dir != "down"`) or not gated by the
LDAP-only policy (missing/wrong `pluginDown`, or a plugin path containing a
space, which strfry would not hot-reload). Only stdlib ERB is needed:
```
ruby site-cookbooks/kosmos_strfry/test/member_bridge_conf_test.rb
```
## Deployment order (as performed)
All of the steps below have been performed; this is the order that was used.
Keep it for rebuilding the service on another host.
0. **HARD PRECONDITION — akkounts `live` branch.** Before *any* converge, the
`live` branch of `kosmos/akkounts` must contain
`extras/strfry/submission-policy.mjs`, `extras/strfry/sync-policy.mjs` **and**
`extras/strfry/ldap-only-policy.ts`. Chef fetches them from
`https://gitea.kosmos.org/kosmos/akkounts/raw/branch/live/extras/strfry/…` at
converge time; if any is missing, the `remote_file` resource fails and the
converge aborts (with a partially configured host). Verify with:
`curl -fsSI https://gitea.kosmos.org/kosmos/akkounts/raw/branch/live/extras/strfry/submission-policy.mjs`
and the same for the other two files. These files are produced by WS1, not by
this repo.
1. **DNS.** `submit.nostr.kosmos.org` is a **CNAME to `lb.kosmos.org`** at Gandi
(already configured). Chef does not manage DNS; the `gandi_dns` Let's Encrypt
challenge cannot succeed without it. Verify it resolves before converging the
proxy nodes.
2. **Relay node.** Assign `role[strfry_submission]`, converge. Creates the
binary (or reuses it), DB, config, policy and `strfry-submission.service`.
The firewall allow-lists the current `role:openresty_proxy` node IPs, so the
proxy nodes should already be registered as Chef nodes.
3. **Proxy nodes.** Converge `role[openresty_proxy]`; this adds the
`submit.nostr.kosmos.org` site and requests the certificate.
4. **Enable the promotion paths.** Only after the worker + staging relay (WS2)
are live: `role[strfry_submission]` sets `strfry.approved_sync.enabled` and
`strfry.member_bridge.enabled` to `true` (role overrides, not the
environment). Converge `role[strfry]`. This deploys `sync-policy.mjs`, the
sync config, `strfry-sync.timer`, `ldap-only-policy.ts`, the member-bridge
config and `strfry-member-bridge.service`.
5. **Verify.**
* `systemctl status strfry-submission` / `strfry-sync.timer` /
`strfry-member-bridge`.
* `curl -s -H 'Accept: application/nostr+json' https://submit.nostr.kosmos.org | jq -r .name`
→ `Kosmos submission relay`. (Without the `Accept` header strfry serves its
HTML info page, which `jq` cannot parse.)
* `journalctl -u strfry-sync` shows accepted events after an approval.
* `journalctl -u strfry-member-bridge` shows `Connected to ws://localhost:7778`
and rejects non-member events (`pluginDown blocked event … Only members can
publish notes on this relay`).
* The production relay's NIP-11 and `_strfry` upstream are unchanged.
## Pre-go-live verification (completed)
* **LMDB concurrency (verified 2026-11-17 on the nuc's `:7777` mirror).** A
`strfry sync --dir down` was run against the same LMDB that the live relay was
serving from. Result: sync exited 0 and the relay answered 13/13 subscriptions
(39 events) during the sync; the relay stayed active and the event count was
unchanged. This is the same access pattern the approved-sync uses on strfry-1
(same DB, separate `strfry sync` process), so no additional lock is needed.
* **No rogue sync path.** Confirmed before the timer was enabled: no external
negentropy/websocket path can produce `sourceType = "Sync"` on the production
relay; the sync policy is fail-closed on the exact staging URL.
## Rollback
* **Sync:** set `strfry.approved_sync.enabled = false` and converge, then
`systemctl disable --now strfry-sync.timer`. (The recipe becomes a no-op, but
it does not stop an already-running timer.)
* **Member bridge:** set `strfry.member_bridge.enabled = false` and converge,
then `systemctl disable --now strfry-member-bridge`.
* **Submission relay / proxy:** remove `kosmos_strfry_submission::nginx` from
`role[openresty_proxy]` and `role[strfry_submission]` from the node, converge,
then `systemctl disable --now strfry-submission`. The DB at
`/var/lib/strfry-submission` can be deleted independently; the production
relay and its database are untouched.
## Node.js caveat (checked before converging)
The Node write policies (`submission-policy.mjs`, `sync-policy.mjs`) are Node 24
ESM scripts, so `role[strfry_submission]` and `role[strfry]` add a
**role-scoped** `kosmos_nodejs.version` override to `24.22.2`. The global
default (`14.21.3`) is deliberately **not** raised. (`ldap-only-policy.ts` is a
Deno script and needs no Node.)
If either role is applied to a host that already runs other Node/JS services,
verify they do not depend on Node 14 *before* converging:
* On **strfry-1**: `blossom` uses Deno (its recipe sets `DENO_DIR`), not Node;
`substr` is the prebuilt Rust binary from the package registry. Neither
currently installs or uses Node, so adding Node 24 is additive. Re-check if
`substr` ever falls back to `deno task server` or if a Node-based service is
added.
* Any other node that gains `role[strfry_submission]` should be checked the same
way.
## Out of scope
* Deploying/converging, DNS changes, certificate issuance, ZeroTier changes.
* The nuc staging relay and the moderator worker (WS2; not Kosmos infra). The
member bridge *is* covered here (`kosmos_strfry::member_bridge`).
* The write policies themselves (WS1, `kosmos/akkounts`).
+1 -1
Submodule nodes updated: 3f7b8a340e...9ad06a6b53.
+1
View File
@@ -30,6 +30,7 @@ production_run_list = %w(
kosmos_rsk::nginx_testnet
kosmos_rsk::nginx_mainnet
kosmos_strfry::nginx
kosmos_strfry_submission::nginx
kosmos_website::default
kosmos_website::redirects
kosmos-akkounts::nginx
+12
View File
@@ -1,9 +1,21 @@
name "strfry"
override_attributes(
# Node 24 LTS runs the fail-closed approved-sync write policy
# (/opt/strfry/sync-policy.mjs). Scoped to this role so the global
# kosmos_nodejs default (14.21.3) stays untouched everywhere else.
"kosmos_nodejs" => {
"version" => "24.22.2"
}
)
run_list %w(
role[ldap_client]
kosmos-nodejs::default
strfry::default
kosmos_strfry::policies
kosmos_strfry::firewall
kosmos_strfry::substr
kosmos_strfry::approved_sync
kosmos_strfry::member_bridge
)
+33
View File
@@ -0,0 +1,33 @@
name "strfry_submission"
override_attributes(
# Node 24 LTS is required by the submission write policy
# (/opt/strfry/submission-policy.mjs). This override is scoped to this role
# only; the global kosmos_nodejs default (14.21.3) is intentionally left
# untouched for every other node.
"kosmos_nodejs" => {
"version" => "24.22.2"
},
# Enable the two promotion paths that feed the production relay from the
# submission pipeline. They are toggled here (role-scoped) rather than in the
# production environment config, so the switches travel with this feature's
# roles. The recipes themselves live in role[strfry] (the relay node runs both
# roles).
"strfry" => {
"approved_sync" => {
"enabled" => true
},
"member_bridge" => {
"enabled" => true
}
}
)
run_list %w(
role[base]
role[kvm_guest]
kosmos-nodejs::default
kosmos_strfry_submission::default
kosmos_strfry_submission::firewall
)
+22
View File
@@ -2,3 +2,25 @@ kosmos_strfry
=============
Installs/configures a strfry relay and its reverse proxy config
## Tests
`test/strfry_sync_conf_test.rb` is a standalone regression check for
`templates/strfry_sync.conf.erb` (the `kosmos_strfry::approved_sync` sync
config). It asserts that the sync's `rejectEventsOlderThanSeconds` age floor is
present and positive, because `0` does *not* disable the check in strfry — it
rejects every synced event. No Chef server or converge is required:
```
ruby site-cookbooks/kosmos_strfry/test/strfry_sync_conf_test.rb
```
`test/member_bridge_conf_test.rb` is a standalone regression check for
`templates/member_bridge.conf.erb` (the `kosmos_strfry::member_bridge` router
config). It asserts that the stream group is one-way (`dir = "down"`) and gated
by the LDAP-only policy (`pluginDown`), with a space-free plugin path so strfry
hot-reloads it. No Chef server or converge is required:
```
ruby site-cookbooks/kosmos_strfry/test/member_bridge_conf_test.rb
```
@@ -1,6 +1,27 @@
node.default["strfry"]["ldap_search_dn"] = "ou=kosmos.org,cn=users,dc=kosmos,dc=org"
node.default["strfry"]["extras_dir"] = "/opt/strfry"
#
# approved sync (WS3): pull worker-approved events from the staging relay into
# the production database. See kosmos_strfry/recipes/approved_sync.rb.
#
node.default["strfry"]["staging_relay_url"] = "ws://10.1.1.183:7779"
node.default["strfry"]["approved_sync"]["enabled"] = false
node.default["strfry"]["approved_sync"]["config_file"] = "/etc/strfry-sync.conf"
node.default["strfry"]["approved_sync"]["policy_url"] = "https://gitea.kosmos.org/kosmos/akkounts/raw/branch/live/extras/strfry/sync-policy.mjs"
#
# member bridge (WS3): live one-way promotion of member-authored events from the
# local submission relay into the production database, gated by the LDAP-only
# write policy. See kosmos_strfry/recipes/member_bridge.rb.
#
node.default["strfry"]["member_bridge"]["enabled"] = false
node.default["strfry"]["member_bridge"]["config_file"] = "/etc/strfry-member-bridge.conf"
node.default["strfry"]["member_bridge"]["subscribe_relay"] = "ws://localhost:7778"
node.default["strfry"]["member_bridge"]["plugin_cmd"] = "#{node["strfry"]["extras_dir"]}/ldap-only-policy.ts"
node.default["strfry"]["member_bridge"]["kinds"] = [0, 3, 5, 360, 30360]
node.default["strfry"]["member_bridge"]["connection_timeout"] = 20
# node.default["substr"]["repo"] = "https://gitea.kosmos.org/kosmos/substr.git"
# node.default["substr"]["revision"] = "master"
node.default["substr"]["version"] = "nightly"
@@ -0,0 +1,124 @@
#
# Cookbook Name:: kosmos_strfry
# Recipe:: approved_sync
#
# Pull moderator-approved events from the nuc staging relay (ws://<nuc>:7779)
# into the production LMDB database used by nostr.kosmos.org, without exposing
# a public write path into it. This is the only way non-member, VLM-approved
# content reaches the production relay.
#
# The sync runs against a DEDICATED config (/etc/strfry-sync.conf) that points
# at the SAME database as the production relay but installs a fail-closed write
# policy (sync-policy.mjs): only events with sourceType="Sync" and a byte-exact
# sourceInfo match for STAGING_RELAY_URL are accepted.
#
# This recipe is a no-op until node["strfry"]["approved_sync"]["enabled"] is
# set to true (e.g. in an environment or a node's role overrides).
#
unless node["strfry"]["approved_sync"]["enabled"]
Chef::Log.info("kosmos_strfry::approved_sync is disabled; skipping staged-event sync.")
return
end
config_file = node["strfry"]["approved_sync"]["config_file"]
staging_url = node["strfry"]["staging_relay_url"]
extras_dir = node["strfry"]["extras_dir"]
if staging_url.to_s.empty?
raise "node['strfry']['staging_relay_url'] must be set when approved_sync is enabled"
end
directory extras_dir do
owner node["strfry"]["user"]
group node["strfry"]["group"]
mode "0755"
end
#
# Fail-closed write policy. Deployed here (and not in ::policies) because it is
# only meaningful together with the sync config.
#
remote_file "#{extras_dir}/sync-policy.mjs" do
source node["strfry"]["approved_sync"]["policy_url"]
owner node["strfry"]["user"]
group node["strfry"]["group"]
mode "0755"
end
#
# Config: identical db + settings as the production relay, except that we keep
# arbitrarily old events (approved long after submission) and swap in the
# sync-only write policy.
#
prod_config = node["strfry"]["config"]
prod_db_params = prod_config["db_params"] || {}
prod_relay = prod_config["relay"] || {}
template config_file do
source "strfry_sync.conf.erb"
owner node["strfry"]["user"]
group node["strfry"]["group"]
mode "0644"
variables db: prod_config["db"],
maxreaders: prod_db_params["maxreaders"] || "256",
mapsize: prod_db_params["mapsize"] || "10995116277760",
no_read_ahead: prod_db_params["no_read_ahead"] || "false",
nofiles: prod_relay["nofiles"] || "524288",
plugin: "node #{extras_dir}/sync-policy.mjs",
timeout_seconds: 10
end
#
# Oneshot sync, driven by a timer. `sync --dir down` is one-way (staging ->
# production) and DOES run the local write policy with sourceType="Sync" and
# sourceInfo=<staging URL> (see strfry src/apps/mesh/cmd_sync.cpp). No --filter:
# the worker only ever publishes approved events to the staging relay, and the
# policy rejects everything else.
#
systemd_unit "strfry-sync.service" do
content({
Unit: {
Description: "strfry approved-event sync (staging -> production)",
Documentation: ["https://github.com/hoytech/strfry"],
After: "strfry.service",
Wants: "network-online.target"
},
Service: {
Type: "oneshot",
User: node["strfry"]["user"],
Group: node["strfry"]["group"],
ExecStart: "/usr/local/bin/strfry --config #{config_file} sync #{staging_url} --dir down",
# sync-policy.mjs compares sourceInfo byte-for-byte against this value.
Environment: ["STAGING_RELAY_URL=#{staging_url}"],
Nice: 10,
ProtectHome: "no",
NoNewPrivileges: "yes",
ProtectSystem: "full",
LimitCORE: "0",
TimeoutStartSec: "600"
},
Install: {
WantedBy: "multi-user.target"
}
})
triggers_reload true
action :create
end
systemd_unit "strfry-sync.timer" do
content({
Unit: {
Description: "Run the approved-event sync every 5 minutes"
},
Timer: {
OnCalendar: "*-*-* *:0/5:00",
Persistent: "true"
},
Install: {
WantedBy: "timers.target"
}
})
triggers_reload true
action [:create, :enable, :start]
end
@@ -0,0 +1,70 @@
#
# Cookbook Name:: kosmos_strfry
# Recipe:: member_bridge
#
# Live, one-way promotion of member-authored events from the local submission
# relay (ws://localhost:7778) into the production database used by
# nostr.kosmos.org.
#
# It runs `strfry router` with a stream group whose `dir` is "down" (so the
# router never watches or forwards the local database) and whose `pluginDown` is
# the LDAP-only write policy (/opt/strfry/ldap-only-policy.ts). Membership is
# therefore decided per event by LDAP; no member list is maintained, and
# non-member events are rejected before they reach the database.
#
# This recipe is a no-op until node["strfry"]["member_bridge"]["enabled"] is set
# to true (in an environment or a node's role overrides).
#
unless node["strfry"]["member_bridge"]["enabled"]
Chef::Log.info("kosmos_strfry::member_bridge is disabled; skipping member bridge.")
return
end
config_file = node["strfry"]["member_bridge"]["config_file"]
template config_file do
source "member_bridge.conf.erb"
owner node["strfry"]["user"]
group node["strfry"]["group"]
mode "0644"
variables subscribe_relay: node["strfry"]["member_bridge"]["subscribe_relay"],
plugin_cmd: node["strfry"]["member_bridge"]["plugin_cmd"],
kinds: node["strfry"]["member_bridge"]["kinds"],
connection_timeout: node["strfry"]["member_bridge"]["connection_timeout"]
end
#
# `strfry router` reads /etc/strfry.conf for the database and the router config
# for the stream groups. It writes accepted events straight into the production
# LMDB (the same multi-process access pattern already used by the approved sync).
#
systemd_unit "strfry-member-bridge.service" do
content({
Unit: {
Description: "strfry member bridge (submission relay -> production, LDAP-only)",
Documentation: ["https://github.com/hoytech/strfry"],
After: "strfry.service",
Wants: "network-online.target"
},
Service: {
Type: "simple",
User: node["strfry"]["user"],
Group: node["strfry"]["group"],
ExecStart: "/usr/local/bin/strfry router #{config_file}",
Restart: "on-failure",
RestartSec: "5",
Nice: 10,
# The LDAP-only policy is a Deno script; Deno caches its modules under the
# strfry user's home, so ProtectHome must stay off (as for strfry.service).
ProtectHome: "no",
NoNewPrivileges: "yes",
ProtectSystem: "full"
},
Install: {
WantedBy: "multi-user.target"
}
})
triggers_reload true
action [:create, :enable, :start]
end
@@ -81,3 +81,14 @@ remote_file "#{extras_dir}/strfry-sync.ts" do
group node["strfry"]["group"]
mode "0644"
end
# LDAP-only policy for the member bridge (kosmos_strfry::member_bridge). It
# reuses ldap-policy.ts above. No `notifies` is needed: strfry watches the
# plugin file's mtime (the pluginDown path contains no spaces) and restarts it
# on change.
remote_file "#{extras_dir}/ldap-only-policy.ts" do
source "#{base_url}/ldap-only-policy.ts"
owner node["strfry"]["user"]
group node["strfry"]["group"]
mode "0755"
end
@@ -0,0 +1,20 @@
# Managed by Chef (kosmos_strfry::member_bridge). Do not edit by hand.
#
# Live member bridge: a `strfry router` stream group subscribes to the local
# submission relay and writes member-authored events into the production relay's
# database. Membership is decided per event by the LDAP-only write policy
# (pluginDown); no member list is maintained here.
#
# `dir = "down"` keeps this strictly one-way: the router never watches or
# forwards the local database.
connectionTimeout = <%= @connection_timeout %>
streams {
members {
dir = "down"
filter = { "kinds": [<%= @kinds.join(', ') %>] }
urls = [ "<%= @subscribe_relay %>" ]
pluginDown = "<%= @plugin_cmd %>"
}
}
@@ -0,0 +1,46 @@
# Managed by Chef (kosmos_strfry::approved_sync). Do not edit by hand.
#
# Dedicated config for `strfry sync` (staging -> production ingestion). It uses
# the SAME LMDB database as the production relay (<%= @db %>), but installs a
# fail-closed write policy that only accepts events synced from the staging
# relay.
#
# Only the settings that matter for a sync-only process are set here; everything
# else falls back to strfry's compiled-in defaults.
db = "<%= @db %>/"
dbParams {
# This opens the production relay's existing LMDB map file; it is NOT a new
# allocation. maxreaders/mapsize must therefore match (or exceed) what the
# running production relay uses -- hence the fallbacks are the production
# relay's values (strfry's 10 TB default mapsize).
maxreaders = <%= @maxreaders %>
mapsize = <%= @mapsize %>
noReadAhead = <%= @no_read_ahead %>
}
events {
# Approved events reach the staging relay long after they were created, so
# the age floor is effectively disabled here (100 years).
#
# NOTE: 0 does NOT disable this check in strfry. strfry computes
# earliest = now - rejectEventsOlderThanSeconds
# so 0 makes earliest == now and rejects EVERY event with
# "created_at too early" -- before the write policy is even consulted.
# Use a large bound instead.
rejectEventsOlderThanSeconds = 3153600000
}
relay {
# strfry raises RLIMIT_NOFILE to this value at startup and exits if it
# exceeds the process hard limit. The compiled-in default (1000000) is above
# the systemd default here (524288), which made the sync fail to start with
# "Unable to set NOFILES limit to 1000000". Set it explicitly, matching the
# production relay config.
nofiles = <%= @nofiles %>
writePolicy {
plugin = "<%= @plugin %>"
timeoutSeconds = <%= @timeout_seconds %>
}
}
@@ -0,0 +1,76 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
#
# Regression check for kosmos_strfry/templates/member_bridge.conf.erb.
#
# The member bridge is a `strfry router` stream group. Two properties must hold,
# or the bridge is either not one-way or not a member gate:
# * `dir` must be "down" (the router must never watch/forward the local DB), and
# * `pluginDown` must be the LDAP-only policy, with a path that contains no
# spaces (strfry only hot-reloads space-free plugin paths).
#
# Renders the real template (no Chef server needed) with the attribute shapes
# kosmos_strfry::member_bridge passes.
#
# Run standalone: ruby site-cookbooks/kosmos_strfry/test/member_bridge_conf_test.rb
require 'erb'
TEMPLATE = File.expand_path('../templates/member_bridge.conf.erb', __dir__)
DEFAULTS = {
subscribe_relay: 'ws://localhost:7778',
plugin_cmd: '/opt/strfry/ldap-only-policy.ts',
kinds: [0, 3, 5, 360, 30360],
connection_timeout: 20
}.freeze
def render(vars)
context = Object.new
vars.each { |name, value| context.instance_variable_set("@#{name}", value) }
# Chef renders templates with the `variables` hash exposed as instance
# variables (@subscribe_relay, ...); mirror that with a bare binding.
ERB.new(File.read(TEMPLATE), trim_mode: '-').result(context.instance_eval { binding })
end
def check(description, vars)
rendered = render(vars)
unless rendered.match?(/^\s*dir\s*=\s*"down"\s*$/)
raise "#{description}: dir must be \"down\""
end
if rendered.match?(/^\s*dir\s*=\s*"(up|both)"\s*$/)
raise "#{description}: dir must not be up/both (the bridge must be one-way)"
end
unless rendered.include?(%(urls = [ "#{vars[:subscribe_relay]}" ]))
raise "#{description}: urls does not contain the subscribe relay"
end
unless rendered.include?(%(pluginDown = "#{vars[:plugin_cmd]}"))
raise "#{description}: pluginDown does not point at the LDAP-only policy"
end
if vars[:plugin_cmd].include?(' ')
raise "#{description}: plugin path must contain no spaces (strfry only hot-reloads space-free paths)"
end
unless rendered.include?(%(filter = { "kinds": [#{vars[:kinds].join(', ')}] }))
raise "#{description}: kinds filter missing or unexpected"
end
unless rendered.include?("connectionTimeout = #{vars[:connection_timeout]}")
raise "#{description}: connectionTimeout missing"
end
puts "ok - #{description}"
end
begin
check('default attributes', DEFAULTS)
puts "\nPASS: member_bridge.conf.erb is one-way and gated by the LDAP-only policy."
rescue StandardError => e
warn "FAIL: #{e.message}"
exit 1
end
+127
View File
@@ -0,0 +1,127 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
#
# Regression check for kosmos_strfry/templates/strfry_sync.conf.erb.
#
# Background: `strfry sync` must accept events that were created long before
# they were approved, so the sync config sets a 100-year age floor. The counter
# intuitive part (see doc/nostr-submission-relay.md) is that 0 does NOT disable
# the check in strfry -- it computes `earliest = now - rejectEventsOlderThanSeconds`,
# so 0 rejects every event. This test renders the real template (no Chef server
# needed) with the same attribute shapes that kosmos_strfry::approved_sync
# passes, and fails if the age floor is missing or non-positive.
#
# Run standalone: ruby site-cookbooks/kosmos_strfry/test/strfry_sync_conf_test.rb
#
# No Chef server / converge required: this only needs the chef gem (for
# ImmutableMash, to mirror the recipe's attribute lookups) and stdlib ERB.
require 'erb'
require 'chef' # Chef::Node::ImmutableMash
TEMPLATE = File.expand_path('../templates/strfry_sync.conf.erb', __dir__)
# The comment in the template mentions "0" a few times; only real settings (a
# `key = value` line with the key at the start of the line) must be validated.
SETTING_RE = /^\s*rejectEventsOlderThanSeconds\s*=\s*(-?\d+)\s*$/.freeze
NOFILES_RE = /^\s*nofiles\s*=\s*(\d+)\s*$/.freeze
EXPECTED_AGE_FLOOR = 3_153_600_000 # 100 years
def render(node)
prod_config = node['strfry']['config']
prod_db_params = prod_config['db_params'] || {}
prod_relay = prod_config['relay'] || {}
# Same variable shapes kosmos_strfry/recipes/approved_sync.rb passes to the
# template resource (keep in sync if that recipe changes).
vars = {
db: prod_config['db'],
maxreaders: prod_db_params['maxreaders'] || '256',
mapsize: prod_db_params['mapsize'] || '10995116277760',
no_read_ahead: prod_db_params['no_read_ahead'] || 'false',
nofiles: prod_relay['nofiles'] || '524288',
plugin: 'node /opt/strfry/sync-policy.mjs',
timeout_seconds: 10
}
# Chef renders templates with the `variables` hash exposed as instance
# variables (@db, @maxreaders, ...); mirror that with a bare binding.
context = Object.new
vars.each { |name, value| context.instance_variable_set("@#{name}", value) }
ERB.new(File.read(TEMPLATE), trim_mode: '-').result(context.instance_eval { binding })
end
def check_node(description, node)
rendered = render(node)
match = rendered.match(SETTING_RE)
raise "#{description}: render has no `rejectEventsOlderThanSeconds = <int>` setting" if match.nil?
value = match[1].to_i
if value <= 0
raise "#{description}: rejectEventsOlderThanSeconds = #{value} (must be > 0; 0 rejects every synced event)"
end
if value != EXPECTED_AGE_FLOOR
raise "#{description}: rejectEventsOlderThanSeconds = #{value}, expected #{EXPECTED_AGE_FLOOR}"
end
unless rendered.include?('rejectEventsOlderThanSeconds = 3153600000')
raise "#{description}: literal `rejectEventsOlderThanSeconds = 3153600000` not found in render"
end
# Sanity-check the other settings the recipe derives, so a broken fallback
# (e.g. an empty db) is caught too.
unless rendered.include?("db = \"#{node['strfry']['config']['db']}/\"")
raise "#{description}: db setting does not match node attribute"
end
raise "#{description}: writePolicy block missing" unless rendered.include?('writePolicy')
# strfry raises RLIMIT_NOFILE to `nofiles` at startup and exits if that
# exceeds the process hard limit. The compiled-in default (1000000) is above
# the systemd default (524288), so the template must set it explicitly.
nofiles_match = rendered.match(NOFILES_RE)
raise "#{description}: render has no `nofiles = <int>` setting" if nofiles_match.nil?
expected_nofiles = (node['strfry']['config']['relay'] || {})['nofiles'] || '524288'
if nofiles_match[1] != expected_nofiles.to_s
raise "#{description}: nofiles = #{nofiles_match[1]}, expected #{expected_nofiles}"
end
puts "ok - #{description} (rejectEventsOlderThanSeconds = #{value}, nofiles = #{nofiles_match[1]})"
end
# Representative cases, using the attribute shapes kosmos_strfry::approved_sync
# reads (see site-cookbooks/strfry/attributes/default.rb for the production
# config shape).
cases = {
'production relay config with explicit db_params' => Chef::Node::ImmutableMash.new(
'strfry' => {
'config' => {
'db' => '/var/lib/strfry',
'db_params' => {
'maxreaders' => '2048',
'mapsize' => '10995116277760',
'no_read_ahead' => 'false'
},
'relay' => {
'nofiles' => '524288'
}
}
}
),
'production relay config with db_params absent (template fallbacks)' => Chef::Node::ImmutableMash.new(
'strfry' => {
'config' => {
'db' => '/var/lib/strfry'
}
}
)
}
begin
cases.each { |description, node| check_node(description, node) }
puts "\nPASS: strfry_sync.conf.erb keeps a positive 100-year age floor."
rescue StandardError => e
warn "FAIL: #{e.message}"
exit 1
end
@@ -0,0 +1,20 @@
Copyright (c) 2024 Kosmos Developers
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,86 @@
kosmos_strfry_submission
========================
Installs and configures the **public submission relay** for Kosmos: a second,
independent strfry instance that accepts *unreviewed* place photos (Nostr kind
`360`, later `30360`) from anyone, on port `7778`, served publicly as
`wss://submit.nostr.kosmos.org`.
It is intentionally **not** `kosmos_strfry` / `role[strfry]`:
* The openresty proxy builds its production `_strfry` upstream from nodes with
`role[strfry]`. A submission node must never end up in that pool.
* It has its own config, database, systemd unit and write policy.
## Recipes
| Recipe | Purpose |
| --- | --- |
| `default` | strfry binary (reused when `strfry::default` installed it), `/opt/strfry/submission-policy.mjs`, `/etc/strfry-submission.conf`, `strfry-submission.service` |
| `firewall` | allow TCP `7778` from the openresty proxy nodes only (resolved via `search(:node, "role:openresty_proxy")`) |
| `nginx` | runs on `role[openresty_proxy]`: TLS cert + `openresty_site` with its own `_strfry_submission` upstream |
## Attributes
| Attribute | Default | Notes |
| --- | --- | --- |
| `strfry_submission.domain` | `submit.nostr.kosmos.org` | public relay hostname |
| `strfry_submission.port` | `7778` | strfry listen port |
| `strfry_submission.config_file` | `/etc/strfry-submission.conf` | |
| `strfry_submission.config.db` | `/var/lib/strfry-submission` | separate LMDB database |
| `strfry_submission.config.db_params.mapsize` | `4 GiB` | hard cap; strfry has no prune |
| `strfry_submission.config.relay.info.name` | `Kosmos submission relay` | NIP-11 name |
| `strfry_submission.config.relay.write_policy.plugin` | `node /opt/strfry/submission-policy.mjs` | |
| `strfry_submission.policy_url` | akkounts `extras/strfry/submission-policy.mjs` | fetched at converge |
| `strfry_submission.policy_env` | `{}` | optional env for the policy |
The write policy itself lives in `kosmos/akkounts` (`extras/strfry/`) and is
fetched at converge time, exactly like the production Deno policy. Its env var
names are documented there.
## Firewall / exposure
Only the openresty proxy nodes (resolved from `role:openresty_proxy`) may reach
`7778`. Public traffic arrives through nginx as
`wss://submit.nostr.kosmos.org`, and the relay takes the client IP from nginx's
`X-Real-IP` header (`relay.realIpHeader = "x-real-ip"`). Because that header is
trusted, a virgo member that could connect to `:7778` directly could forge it
and defeat the policy's **per-IP** token bucket — hence the narrow allow-list
(the **per-author** bucket, keyed on `event.pubkey`, is unaffected either way).
The member bridge on strfry-1 uses `ws://localhost:7778` (loopback) and is not
affected by the allow-list.
Everything else on the host (production relay `7777`, blossom, substr) is
unaffected.
## Node.js
The write policy is a plain Node ESM script and needs **Node 24 LTS**. Provision
it via `role[strfry_submission]`, which sets a role-scoped
`kosmos_nodejs.version` override. Do not raise the global default (14.21.3).
If this role is applied to a host that also runs blossom/substr (e.g. strfry-1),
verify those services do not depend on Node 14 before converging — see
`doc/nostr-submission-relay.md`.
## Deployment
1. DNS: `submit.nostr.kosmos.org` is a **CNAME to `lb.kosmos.org`** (the
openresty proxy load balancer) at Gandi. **Chef does not manage DNS**, and the
Let's Encrypt certificate cannot be issued without it. The CNAME is already in
place; verify it resolves before converging the proxy nodes.
2. Provision/assign `role[strfry_submission]` and converge the relay node.
3. Converge the openresty proxy nodes (`role[openresty_proxy]`), which adds the
`kosmos_strfry_submission::nginx` site.
4. Verify: `curl -s -H 'Accept: application/nostr+json' https://submit.nostr.kosmos.org`
returns the NIP-11 document with name `Kosmos submission relay` (without the
`Accept` header strfry serves its HTML info page); `systemctl status
strfry-submission`.
Rollback: remove `kosmos_strfry_submission::nginx` from the proxy run list,
converge, and stop/disable `strfry-submission` on the relay node. The database
lives in `/var/lib/strfry-submission` and can be deleted independently from the
production relay.
This cookbook is deployed to production; see `doc/nostr-submission-relay.md`
for the full runbook and rollback.
@@ -0,0 +1,49 @@
#
# Cookbook Name:: kosmos_strfry_submission
# Attributes:: default
#
node.default["strfry_submission"]["domain"] = "submit.nostr.kosmos.org"
node.default["strfry_submission"]["port"] = 7778
node.default["strfry_submission"]["config_file"] = "/etc/strfry-submission.conf"
# Same directory as the production Deno policy: both live under /opt/strfry.
node.default["strfry_submission"]["extras_dir"] = "/opt/strfry"
# Node write policy, fetched from kosmos/akkounts.
node.default["strfry_submission"]["policy_url"] = "https://gitea.kosmos.org/kosmos/akkounts/raw/branch/live/extras/strfry/submission-policy.mjs"
# Extra environment variables for the write policy plugin (inherited from the
# strfry process). Empty means "use the policy's built-in defaults".
node.default["strfry_submission"]["policy_env"] = {}
node.default["strfry_submission"]["config"] = {
db: "/var/lib/strfry-submission",
db_params: {
# This relay is a small, disposable landing area for *unreviewed* content,
# so cap the LMDB map well below the production relay's 10 TB: a flood must
# not be able to fill the disk (strfry has no prune).
mapsize: 4 * 1024 * 1024 * 1024, # 4 GiB
maxreaders: 128
},
events: {
max_event_size: 65536
},
relay: {
bind: "0.0.0.0",
port: 7778,
real_ip_header: "x-real-ip",
info: {
name: "Kosmos submission relay",
description: "Public relay for submitted place photos. Content is reviewed before it is republished to nostr.kosmos.org.",
contact: "ops@kosmos.org"
},
write_policy: {
plugin: "node /opt/strfry/submission-policy.mjs",
timeout_seconds: 10
},
logging: {
invalid_events: true
}
}
}
@@ -0,0 +1,13 @@
name 'kosmos_strfry_submission'
maintainer 'Kosmos'
maintainer_email 'ops@kosmos.org'
license 'MIT'
description 'Installs/configures the public nostr submission relay (a second strfry instance)'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.0'
chef_version '>= 18.0'
depends 'firewall'
depends 'kosmos-base'
depends 'kosmos_openresty'
depends 'strfry'
@@ -0,0 +1,158 @@
#
# Cookbook Name:: kosmos_strfry_submission
# Recipe:: default
#
# A second, independent strfry instance: the public submission relay
# (submit.nostr.kosmos.org, port 7778). Writes are open to everyone and gated
# only by the Node write policy in /opt/strfry/submission-policy.mjs.
#
# This recipe deliberately does NOT run strfry::default / role[strfry]: the
# openresty proxy builds its production `_strfry` upstream from nodes with
# role[strfry], and this relay must never end up in it.
#
unless platform?("ubuntu")
raise "This recipe only supports Ubuntu installs at the moment"
end
extras_dir = node["strfry_submission"]["extras_dir"]
config_file = node["strfry_submission"]["config_file"]
db_dir = node["strfry_submission"]["config"]["db"]
#
# Reuse the strfry binary that strfry::default installs on a shared host, and
# install the same binary (same repo/revision/download_url attributes) when
# this role owns a dedicated node. strfry::default stays the source of truth
# for upgrades; we only fill the gap when the binary is not already present.
#
unless ::File.exist?("/usr/local/bin/strfry")
if node["strfry"]["download_url"]
remote_file "/usr/local/bin/strfry" do
source node["strfry"]["download_url"]
checksum node["strfry"]["checksum"]
mode "0755"
show_progress true
notifies :restart, "service[strfry-submission]", :delayed
end
else
%w[
git build-essential libssl-dev zlib1g-dev liblmdb-dev libflatbuffers-dev
libsecp256k1-dev libzstd-dev
].each do |pkg|
package pkg
end
git "/usr/local/src/strfry" do
repository node["strfry"]["repo"]
revision node["strfry"]["revision"]
enable_submodules true
notifies :run, "execute[compile strfry]", :immediately
end
execute "compile strfry" do
cwd "/usr/local/src/strfry"
command "make setup-golpe && make -j$(nproc)"
action :nothing
notifies :create, "link[/usr/local/bin/strfry]", :immediately
notifies :restart, "service[strfry-submission]", :delayed
end
link "/usr/local/bin/strfry" do
to "/usr/local/src/strfry/strfry"
action :nothing
end
end
end
group node["strfry"]["group"]
user node["strfry"]["user"] do
gid node["strfry"]["group"]
manage_home true
shell "/bin/bash"
end
directory db_dir do
owner node["strfry"]["user"]
group node["strfry"]["group"]
mode "0755"
end
directory extras_dir do
owner node["strfry"]["user"]
group node["strfry"]["group"]
mode "0755"
end
#
# Write policy (plain Node ESM, no dependencies), fetched from kosmos/akkounts
# exactly like kosmos_strfry::policies fetches the production Deno policy.
#
remote_file "#{extras_dir}/submission-policy.mjs" do
source node["strfry_submission"]["policy_url"]
owner node["strfry"]["user"]
group node["strfry"]["group"]
mode "0755"
notifies :restart, "service[strfry-submission]", :delayed
end
#
# Config. Rendered from the generic strfry config template so it always stays
# in sync with the config options supported by the installed strfry.
#
template config_file do
source "strfry.conf.erb"
cookbook "strfry"
owner node["strfry"]["user"]
group node["strfry"]["group"]
mode "0644"
variables config: node["strfry_submission"]["config"]
notifies :restart, "service[strfry-submission]", :delayed
end
service "strfry-submission" do
action :nothing
end
service_settings = {
Type: "simple",
User: node["strfry"]["user"],
Group: node["strfry"]["group"],
ExecStart: "/usr/local/bin/strfry --config #{config_file} relay",
Restart: "on-failure",
RestartSec: "5",
ProtectHome: "no",
NoNewPrivileges: "yes",
ProtectSystem: "full",
LimitCORE: "1000000000",
LimitNOFILE: "524288",
# Best-effort caps so this open, potentially abused relay cannot starve the
# production relay and blossom/substr that share the host.
Nice: 10,
MemoryHigh: "2G",
MemoryMax: "3G"
}
policy_env = node["strfry_submission"]["policy_env"] || {}
unless policy_env.empty?
service_settings[:Environment] = policy_env.map { |key, value| "#{key}=#{value}" }
end
systemd_unit "strfry-submission.service" do
content({
Unit: {
Description: "strfry public submission relay",
Documentation: ["https://github.com/hoytech/strfry"]
},
Service: service_settings,
Install: {
WantedBy: "multi-user.target"
}
})
triggers_reload true
action :create
end
service "strfry-submission" do
action [:enable, :start]
end
@@ -0,0 +1,32 @@
#
# Cookbook Name:: kosmos_strfry_submission
# Recipe:: firewall
#
# Only the openresty proxy nodes may reach the relay directly. The relay trusts
# the client IP from the `X-Real-IP` header (relay.realIpHeader = "x-real-ip"),
# so any other virgo member with direct access to :7778 could forge that header
# and defeat the per-IP token bucket in the write policy. (The per-author bucket
# is keyed on event.pubkey and is unaffected.) Everything else must go through
# nginx.
#
include_recipe "kosmos-base::firewall"
relay_port = node["strfry_submission"]["port"]
proxy_hosts = search(:node, "role:openresty_proxy").map do |n|
n["knife_zero"] && n["knife_zero"]["host"]
end.compact.uniq.sort
if proxy_hosts.empty?
Chef::Log.warn("No node found with 'openresty_proxy' role; not opening port #{relay_port}")
else
proxy_hosts.each do |host|
firewall_rule "strfry-submission-#{host}" do
port relay_port
source host
protocol :tcp
command :allow
end
end
end
@@ -0,0 +1,38 @@
#
# Cookbook Name:: kosmos_strfry_submission
# Recipe:: nginx
#
# Reverse proxy for the public submission relay. Runs on the openresty proxy
# nodes (role[openresty_proxy]) and uses its own `_strfry_submission` upstream,
# so the submission relay is never mixed into the production `_strfry` pool.
#
# NOTE: submit.nostr.kosmos.org needs a manual A/AAAA record at Gandi that
# points at the proxy node(s) before the Let's Encrypt certificate can be
# issued. Chef does not manage DNS here.
#
domain = node["strfry_submission"]["domain"]
upstream_hosts = []
search(:node, "role:strfry_submission").each do |node|
upstream_hosts << node["knife_zero"]["host"]
end
if upstream_hosts.empty?
Chef::Log.warn("No node found with 'strfry_submission' role. Not configuring nginx site.")
return
end
tls_cert_for domain do
auth "gandi_dns"
action :create
end
openresty_site domain do
template "nginx_conf_strfry_submission.erb"
variables domain: domain,
upstream_port: node["strfry_submission"]["port"],
upstream_hosts: upstream_hosts,
ssl_cert: "/etc/letsencrypt/live/#{domain}/fullchain.pem",
ssl_key: "/etc/letsencrypt/live/#{domain}/privkey.pem"
end
@@ -0,0 +1,30 @@
upstream _strfry_submission {
<% @upstream_hosts.each do |host| %>
server <%= host %>:<%= @upstream_port || "7778" %>;
<% end %>
}
server {
server_name <%= @domain %>;
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl http2;
listen <%= "[#{node['openresty']['listen_ipv6']}]" %>:443 ssl http2;
access_log "/var/log/nginx/<%= @domain %>.access.log";
error_log "/var/log/nginx/<%= @domain %>.error.log";
ssl_certificate <%= @ssl_cert %>;
ssl_certificate_key <%= @ssl_key %>;
location /metrics {
return 404;
}
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://_strfry_submission;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}