Deploy with Docker Compose / deploy (push) Successful in 1m1s
Quartz was already replaced by silverbullet-public; its build context moves to .deprecated/quartz. Hasura and autoheal are removed from the stack, with their compose services (and Hasura's nginx blocks) kept verbatim under .deprecated/ alongside a README on how to bring each back. Removes the /hasura/ route from both nginx templates and the envsubst allow-list, and updates the docs and comments that referred to the three services. With autoheal gone nothing restarts an unhealthy container; the healthchecks are now informational only, and the docs say so. Co-Authored-By: Claude Opus 5.5 <[email protected]>
259 lines
11 KiB
Plaintext
259 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_silverbullet http://$SILVERBULLET_HOST:$SILVERBULLET_PORT;
|
|
set $upstream_silverbullet_public http://$SILVERBULLET_PUBLIC_HOST:$SILVERBULLET_PUBLIC_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 /sb/. 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 /sb/ 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 /notes {
|
|
return 301 /notes/;
|
|
}
|
|
|
|
# PUBLIC notes viewer (read-only SilverBullet). The deny blocks are
|
|
# the privacy boundary: SB_SPACE_IGNORE hides files from the list but
|
|
# NOT from a direct /.fs/ fetch, a page URL (server-rendered), or
|
|
# /.fs/.git/. Full explanation in nginx.conf.template; keep the two in
|
|
# step.
|
|
location ~* ^/notes/(.*/)?(private|templates)(/|$) {
|
|
return 404;
|
|
}
|
|
|
|
location ~ ^/notes/.+/\. {
|
|
return 404;
|
|
}
|
|
|
|
location ^~ /notes/.revisions {
|
|
return 404;
|
|
}
|
|
|
|
location /notes/ {
|
|
proxy_pass $upstream_silverbullet_public;
|
|
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 admin-only EDITOR for the vault /notes/ publishes.
|
|
# 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;
|
|
}
|