X-Forwarded-For se ponia con $proxy_add_x_forwarded_for, que APENDE lo que mande el cliente, y el API lee la primera entrada — asi que cualquiera elegia la IP que quedaba registrada contra el en el activity log. CF-Connecting-IP no la tocaba nadie y es la que el API mira primero. Ahora se sobrescribe con $remote_addr y la de Cloudflare se descarta salvo que pongas CF_CONNECTING_IP=$http_cf_connecting_ip, que solo es correcto con Cloudflare de verdad delante. .env.example afirmaba que el stack venia correcto de fabrica; no era cierto. location /api/ pasa a ^~ para que gane a los location con regex: sin eso una ruta como /api/algo.json la atraparia el bloque \.(js|css|json|html)$ y se buscaria en disco en vez de proxearse. Hoy no rompe nada, manana si. Y cuatro cabeceras de seguridad, repetidas en los dos location con regex porque add_header dentro de un location reemplaza los heredados en vez de sumarse. Sin HSTS ni CSP completa a proposito: eso sigue siendo del reverse proxy. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
128 lines
6.6 KiB
Bash
128 lines
6.6 KiB
Bash
# Copy this file to ".env" and adjust for your setup, then: docker compose up -d
|
|
#
|
|
# ── Local testing (default) ────────────────────────────────────────────────
|
|
# Works out of the box on the machine running Docker. Open http://localhost:8080
|
|
RP_ID=localhost
|
|
ORIGIN=http://localhost:8080
|
|
WEB_PORT=8080
|
|
RP_NAME=openGym
|
|
|
|
# ── Real deployment behind your own HTTPS domain ───────────────────────────
|
|
# Passkeys are bound to the exact hostname, and browsers only allow them over
|
|
# HTTPS (localhost is the one exception). Put openGym behind a reverse proxy /
|
|
# tunnel that terminates TLS for your domain, then set:
|
|
#
|
|
# RP_ID=gym.example.com
|
|
# ORIGIN=https://gym.example.com
|
|
# WEB_PORT=8080
|
|
# RP_NAME=openGym
|
|
#
|
|
# (Point your proxy at the web container's WEB_PORT. See docs/SELF_HOSTING.md.)
|
|
|
|
# ── Admin dashboard & invite-only signup (optional) ────────────────────────
|
|
# Both off by default — a fresh instance has open signup and no admin.
|
|
#
|
|
# Make yourself an admin: register your own passkey profile first, find your
|
|
# user id in ./data/db.json ("users"[].id), then list it here (comma-separated
|
|
# for several admins). Admins get an "Admin dashboard" link in Settings to see
|
|
# users, disable accounts, generate invite codes and view workout history.
|
|
#
|
|
# ADMIN_UIDS=youruserid,anotheradmin
|
|
#
|
|
# Require an invite code to create new profiles (existing accounts keep working;
|
|
# generate the codes from the admin dashboard):
|
|
#
|
|
# INVITE_ONLY=1
|
|
#
|
|
# Remove the "Continue without account" button, so a profile is the only way in.
|
|
# Guest mode keeps everything in the browser and never touches this server, but
|
|
# on an instance meant for a known set of people it is still the wrong front
|
|
# door. Anyone already inside as a guest is signed out on their next visit; the
|
|
# data they made stays in that browser. Defaults to on (guests allowed):
|
|
#
|
|
# ALLOW_GUEST=0
|
|
|
|
# ── Activity log (optional) ────────────────────────────────────────────────
|
|
# The admin dashboard shows an activity log: who signed in, who tried and
|
|
# failed, and every admin action (disabling an account, creating or revoking an
|
|
# invite code). It lives in ./data/audit.log, one JSON object per line, so you
|
|
# can also just read it with `tail` or `jq`.
|
|
#
|
|
# It is ON by default. It records strictly less than this instance already
|
|
# holds — every profile is in db.json and every workout is in state-<uid>.json,
|
|
# both readable by any admin — and a log that ships switched off tells you
|
|
# nothing on the day you need it. Turn it off completely with:
|
|
#
|
|
# AUDIT_LOG=0
|
|
#
|
|
# Retention is a cap, not an archive. Whichever limit is reached first wins;
|
|
# set either to 0 to disable that limit:
|
|
#
|
|
# AUDIT_MAX=5000 # events kept
|
|
# AUDIT_DAYS=90 # days kept
|
|
#
|
|
# IP addresses are the one thing that is OFF unless you ask, because they are
|
|
# the only field here that says where somebody physically is. They are also the
|
|
# only way to tell one failed sign-in from twenty. Three settings:
|
|
#
|
|
# AUDIT_IP=off # default — no addresses at all
|
|
# AUDIT_IP=net # network only: 203.0.113.0/24, 2001:db8:1::/48
|
|
# AUDIT_IP=full # the whole address
|
|
#
|
|
# The address is read from CF-Connecting-IP, then the first entry of
|
|
# X-Forwarded-For, then X-Real-IP, and finally the connecting socket itself if
|
|
# none of those is present.
|
|
#
|
|
# A forwarded-for header is only worth anything if whatever sits in front
|
|
# OVERWRITES it instead of passing a client-supplied one through — otherwise a
|
|
# caller simply states the address it would like logged. The web container now
|
|
# overwrites X-Forwarded-For and X-Real-IP with the real peer, and DROPS
|
|
# CF-Connecting-IP, so the bundled stack records an address nobody can choose.
|
|
# (Before, X-Forwarded-For was appended to rather than replaced, and
|
|
# CF-Connecting-IP was passed straight through — both were forgeable.)
|
|
#
|
|
# Cloudflare is first in that list on purpose: a Cloudflare tunnel does not put
|
|
# the visitor in X-Forwarded-For at all, so that header would otherwise record
|
|
# the tunnel itself and look perfectly plausible. If — and only if — Cloudflare
|
|
# is genuinely in front of you, let its header through again:
|
|
#
|
|
# CF_CONNECTING_IP=$http_cf_connecting_ip
|
|
#
|
|
# That is safe there because Cloudflare sets the header itself, replacing
|
|
# anything the client sent. Anywhere else, leave it unset.
|
|
|
|
# ── Session length (optional) ──────────────────────────────────────────────
|
|
# How long a sign-in lasts, in days. Default 90 — long enough that people who
|
|
# train regularly never see a login screen, short enough that a stolen cookie
|
|
# doesn't stay good forever. Lower it for an instance on the open internet,
|
|
# raise it for a private one. Only affects new sign-ins; cookies already handed
|
|
# out keep the lifetime they were issued with. Users can end every session on
|
|
# every device themselves with "Sign out everywhere" in Settings.
|
|
#
|
|
# SESSION_DAYS=90
|
|
|
|
# ── Fitting into an existing stack (optional) ──────────────────────────────
|
|
# The defaults assume openGym is on its own: an API service called `api` on
|
|
# port 3000, and nginx listening on 80 inside the web container. If you are
|
|
# merging this into a compose file that already has an `api`, or you front the
|
|
# web container with your own reverse proxy, move them here. The web image
|
|
# renders its nginx config at start-up, so these apply to a prebuilt image and
|
|
# need no rebuild. BACKEND and PORT together are what /api is proxied to, so
|
|
# they must name a service the web container can reach on your network:
|
|
#
|
|
# NGINX_PORT=80
|
|
# BACKEND=api
|
|
# PORT=3000
|
|
|
|
# ── Notifications (optional) ───────────────────────────────────────────────
|
|
# Push works out of the box — nothing to set. VAPID keys are generated on first
|
|
# run and saved to ./data/vapid.json. Each user's browser reports its own
|
|
# timezone automatically, so the workout-day reminder fires at their local
|
|
# time regardless of where the server runs or where they're travelling.
|
|
#
|
|
# Push services want a contact address for whoever operates the server, in case
|
|
# they need to get in touch about your pushes. Defaults to your ORIGIN, which is
|
|
# fine; set a mailto: if you would rather they mailed you:
|
|
#
|
|
# VAPID_SUBJECT=mailto:you@example.com
|