Files
MrAlders0n b0323b84b3 docs: update for Beacon 2.0.0 (#9)
Upgrade guide (fresh database, config changes that fail startup), nginx and
Caddy reverse proxy examples with X-Real-IP and trusted_proxies, a fixed
compose subnet, and the API contract and design doc brought up to date.
2026-10-02 16:53:36 -04:00

65 lines
2.2 KiB
Plaintext

# Beacon behind a host nginx: /api/* and /ws go to beacon-server, everything else to beacon-web.
# Drop into /etc/nginx/conf.d/ (or sites-available), set server_name and the certificate paths,
# then `nginx -t && systemctl reload nginx`.
#
# Upstreams assume the containers publish on loopback, e.g. in docker-compose.yml:
# app: ports: ["127.0.0.1:8080:8080"]
# web: ports: ["127.0.0.1:8081:80"]
#
# beacon-server must trust this proxy in config.yaml. Requests to a published Docker port
# arrive from the compose network's gateway, so trust that network:
# server:
# trusted_proxies: [172.30.0.0/24]
# For beacon-server running directly on the host, use ["127.0.0.1/32", "::1/128"] instead.
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
listen [::]:80;
server_name beacon.example.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
http2 on; # nginx 1.25.1+; on older versions use `listen 443 ssl http2;` instead
server_name beacon.example.com;
ssl_certificate /etc/letsencrypt/live/beacon.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/beacon.example.com/privkey.pem;
access_log /var/log/nginx/beacon-access.log combined;
location /api/ {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
# beacon-server reads the client IP only from X-Real-IP; always overwrite it
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
location = /ws {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
# the WebSocket Origin check compares against Host, so pass the public one through
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
# the server drops sockets idle for 90s; clients ping every 30s
proxy_read_timeout 120s;
proxy_send_timeout 120s;
proxy_buffering off;
}
location / {
proxy_pass http://127.0.0.1:8081;
proxy_set_header Host $host;
}
}