Deploy with Docker Compose / deploy (push) Successful in 2m17s
Quartz renders the vault but has no write path, so editing a note meant editing files on the Pi or pushing through git. SilverBullet serves the same vault as an editable PWA at /sb/, behind the same nginx admin gate /notes/ uses. Quartz stays as the read view; its --serve watcher picks up SilverBullet's writes, so /notes/ follows within seconds. The vault is now the `notes` repo rather than `obsidian_vault`, and the silverbullet-git sidecar commits and pushes what the editor writes while pulling what Obsidian pushes from elsewhere. The vault's own deploy workflow has been removed in that repo: it pulled from the old remote and restarted quartz, and a second git process in the same clone would race the sidecar. Notes on the configuration: - Single-space mode, auto-detected because the mounted folder is not empty. SilverBullet writes no database or metadata into the vault, so the folder stays plain markdown that quartz and Obsidian still understand. - /sb/ is the one proxied app whose prefix is NOT stripped. SB_URL_PREFIX=/sb tells the PWA its own base path and its service-worker scope is built from that; stripping the prefix serves a blank page with nothing in the log. - SB_SPACE_IGNORE mirrors quartz's ignorePatterns and must be newline separated. A comma separated list is accepted silently and does nothing. - No SB_USER is set, so the container is open to anything reaching it on app-network. The nginx auth_request gate is the only protection. - The sidecar runs as uid 1000 to match the vault's ownership, and is a separate container rather than SilverBullet's own shell backend, which would hand anyone past the nginx gate command execution inside the container. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01BCQFvkvorAw1xwhd5gL2qZ
264 lines
11 KiB
Plaintext
264 lines
11 KiB
Plaintext
# =============================================================================
|
|
# nginx_dev.conf.template — SHARED BODY of the dev :80 and :443 server blocks.
|
|
#
|
|
# WHY THIS FILE EXISTS
|
|
# In dev the :80 and :443 server blocks are byte-for-byte identical apart
|
|
# from `listen` and the self-signed `ssl_certificate` pair. They used to be
|
|
# ~190 duplicated lines, so every routing fix had to be made twice and could
|
|
# silently drift. Both blocks now `include` this partial instead.
|
|
#
|
|
# HOW IT IS RENDERED
|
|
# nginx/entrypoint.sh runs the SAME envsubst allow-list over this file as
|
|
# over nginx_dev.conf.template, writing the result to
|
|
# /etc/nginx/nginx_dev_common.conf — which is exactly the path the two
|
|
# `include` directives in the rendered nginx.conf point at. If you add
|
|
# a new substituted variable here, it must also be added to ENVSUBST_VARS in
|
|
# the entrypoint, or it will reach nginx unsubstituted.
|
|
#
|
|
# WHAT BELONGS HERE
|
|
# Everything inside a `server { ... }` block: the `set $upstream_*` vars and
|
|
# every `location`. NOT `listen`, `server_name` or the ssl_certificate lines
|
|
# (those differ between the two blocks), and NOT the enclosing braces — this
|
|
# file must be brace-balanced on its own.
|
|
#
|
|
# This is the DEV file only. Production uses a single :443 server block in
|
|
# nginx.conf.template and needs no partial.
|
|
# =============================================================================
|
|
set $upstream_backend http://$BACKEND_HOST:$BACKEND_PORT;
|
|
set $upstream_icecast http://$ICECAST_HOST:$ICECAST_PORT;
|
|
set $upstream_gitea http://$GITEA_HOST:$GITEA_PORT;
|
|
set $upstream_hasura http://$HASURA_HOST:$HASURA_PORT;
|
|
set $upstream_quartz http://$QUARTZ_HOST:$QUARTZ_PORT;
|
|
set $upstream_silverbullet http://$SILVERBULLET_HOST:$SILVERBULLET_PORT;
|
|
set $upstream_python http://$PYTHON_HOST:$PYTHON_PORT;
|
|
|
|
# PRIVATE attachments (admin-only). Attachments on *private* chat
|
|
# messages are written by the backend to /backend/uploads/private/ and
|
|
# must not be readable by the public, so this subpath is put behind the
|
|
# same admin `auth_request` used for /hasura/ and /notes/. nginx picks
|
|
# the LONGEST matching prefix location, so this block wins over the
|
|
# public /uploads/ block below for /uploads/private/* regardless of
|
|
# ordering. Same three hardening headers as the public block, because
|
|
# the bytes are just as attacker-supplied.
|
|
location /uploads/private/ {
|
|
auth_request /internal/auth/admin-validate;
|
|
error_page 401 403 = @auth_denied;
|
|
alias /uploads/private/;
|
|
add_header X-Content-Type-Options nosniff always;
|
|
add_header Content-Disposition "inline" always;
|
|
add_header Content-Security-Policy "default-src 'none'; img-src 'self'; style-src 'none'; script-src 'none'" always;
|
|
}
|
|
|
|
location /uploads/ {
|
|
alias /uploads/;
|
|
add_header X-Content-Type-Options nosniff always;
|
|
add_header Content-Disposition "inline" always;
|
|
add_header Content-Security-Policy "default-src 'none'; img-src 'self'; style-src 'none'; script-src 'none'" always;
|
|
}
|
|
|
|
location / {
|
|
proxy_pass http://vue:5173;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
proxy_set_header Host $host;
|
|
}
|
|
|
|
location $BACKEND_ENDPOINT {
|
|
return 301 $BACKEND_ENDPOINT/;
|
|
}
|
|
|
|
location $BACKEND_ENDPOINT/ws {
|
|
rewrite ^$BACKEND_ENDPOINT/(.*)$ /$1 break;
|
|
proxy_pass $upstream_backend;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
|
|
location $BACKEND_ENDPOINT/auth/login {
|
|
limit_req zone=login burst=3 nodelay;
|
|
rewrite ^$BACKEND_ENDPOINT/(.*)$ /$1 break;
|
|
proxy_pass $upstream_backend;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
|
|
location $BACKEND_ENDPOINT/messages/upload {
|
|
limit_req zone=upload burst=3 nodelay;
|
|
rewrite ^$BACKEND_ENDPOINT/(.*)$ /$1 break;
|
|
proxy_pass $upstream_backend;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
|
|
location $BACKEND_ENDPOINT/ {
|
|
limit_req zone=api burst=20 nodelay;
|
|
rewrite ^$BACKEND_ENDPOINT/(.*)$ /$1 break;
|
|
proxy_pass $upstream_backend;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
|
|
location /radio {
|
|
return 301 /radio/;
|
|
}
|
|
|
|
# The icecast ADMIN UI (/radio/admin/*) is a full station-control
|
|
# surface — kick sources, change metadata — protected only by the
|
|
# icecast admin password, and it was reachable from the public
|
|
# internet through this proxy. Put it behind the same admin
|
|
# `auth_request` as /hasura/ and /notes/ so an admin session cookie is
|
|
# required before the request ever reaches icecast. Longest-prefix
|
|
# matching means this wins over /radio/ below; listener traffic
|
|
# (/radio/$ICECAST_MOUNT, /radio/status.xsl) is untouched.
|
|
location /radio/admin/ {
|
|
auth_request /internal/auth/admin-validate;
|
|
error_page 401 403 = @auth_denied;
|
|
rewrite ^/radio/(.*)$ /$1 break;
|
|
proxy_pass $upstream_icecast;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
|
|
location /radio/ {
|
|
rewrite ^/radio/(.*)$ /$1 break;
|
|
proxy_pass $upstream_icecast;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
|
|
location /gitea {
|
|
return 301 /gitea/;
|
|
}
|
|
|
|
location /gitea/ {
|
|
rewrite ^/gitea/(.*)$ /$1 break;
|
|
proxy_pass $upstream_gitea;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
|
|
location /hasura {
|
|
return 301 /hasura/;
|
|
}
|
|
|
|
location /hasura/ {
|
|
auth_request /internal/auth/admin-validate;
|
|
error_page 401 403 = @auth_denied;
|
|
rewrite ^/hasura/(.*)$ /$1 break;
|
|
proxy_pass $upstream_hasura;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
}
|
|
|
|
location /notes {
|
|
return 301 /notes/;
|
|
}
|
|
|
|
location /notes/ {
|
|
auth_request /internal/auth/admin-validate;
|
|
error_page 401 403 = @auth_denied;
|
|
rewrite ^/notes/(.*)$ /$1 break;
|
|
proxy_pass $upstream_quartz;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
|
|
location /sb {
|
|
return 301 /sb/;
|
|
}
|
|
|
|
# SilverBullet: the editor for the same vault quartz renders at /notes/.
|
|
# Deliberately NO prefix-strip rewrite, unlike every other proxied app
|
|
# here. SilverBullet is a PWA told its own base path via SB_URL_PREFIX=/sb,
|
|
# and its service worker scope and asset URLs are built from that. Strip
|
|
# the prefix and the app loads a blank page with no error in the log.
|
|
# Upgrade/Connection are for its sync websocket.
|
|
location /sb/ {
|
|
auth_request /internal/auth/admin-validate;
|
|
error_page 401 403 = @auth_denied;
|
|
proxy_pass $upstream_silverbullet;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
|
|
location /py {
|
|
return 301 /py/;
|
|
}
|
|
|
|
# /py/hotels/search[/stream] and /py/hotels/scan/stream: long-running NDJSON streams
|
|
location ~ ^/py/hotels/(search|scan) {
|
|
# Public, up-to-a-minute upstream call with a single search slot: keep it to a few per minute per IP
|
|
limit_req zone=hotel_search burst=2 nodelay;
|
|
proxy_read_timeout 300s;
|
|
proxy_send_timeout 300s;
|
|
# The stream variant sends NDJSON progress lines; pass them through as they arrive
|
|
proxy_buffering off;
|
|
proxy_cache off;
|
|
gzip off;
|
|
rewrite ^/py/(.*)$ /$1 break;
|
|
proxy_pass $upstream_python;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
|
|
location /py/ {
|
|
limit_req zone=api burst=20 nodelay;
|
|
# Hotel search blocks for up to a few minutes while it calls Travelodge and TfL
|
|
proxy_read_timeout 300s;
|
|
proxy_send_timeout 300s;
|
|
rewrite ^/py/(.*)$ /$1 break;
|
|
proxy_pass $upstream_python;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
|
|
location = /internal/auth/admin-validate {
|
|
internal;
|
|
rewrite ^ /auth/validate-admin break;
|
|
proxy_pass $upstream_backend;
|
|
proxy_pass_request_body off;
|
|
proxy_set_header Content-Length "";
|
|
proxy_set_header Cookie $http_cookie;
|
|
}
|
|
|
|
location @auth_denied {
|
|
return 302 /admin/login?redirect=$request_uri;
|
|
}
|