Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

.env.example: single-quote CF_CONNECTING_IP so Compose does not blank it

APN Carmine13b93cd20556
diff --git a/.env.example b/.env.example
index d9ff57134..5699b2685 100644
--- a/.env.example
+++ b/.env.example
@@ -125,10 +125,15 @@ RP_NAME=openGym
# 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
+# 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.
+#
+# Keep the single quotes: Compose expands $variables inside .env too, so
+# without them the value comes out empty (with a "variable is not set"
+# warning) and the header is still dropped. nginx has to receive
+# $http_cf_connecting_ip literally.
# ── Session length (optional) ──────────────────────────────────────────────
# How long a sign-in lasts, in days. Default 90 — long enough that people who
diff --git a/SECURITY.md b/SECURITY.md
index 92b76bd0d..67ffe1d60 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -311,8 +311,9 @@ Read this before hosting openGym for anyone other than yourself.
the connecting socket — so it is only as trustworthy as whatever sits in front, which has to
*overwrite* those headers rather than pass a client-supplied one through. The bundled web
container now does: it replaces `X-Forwarded-For`/`X-Real-IP` with the real peer and drops
- `CF-Connecting-IP` unless you set `CF_CONNECTING_IP=$http_cf_connecting_ip`, which is correct
- only with Cloudflare genuinely in front. Before that it appended to `X-Forwarded-For` and
+ `CF-Connecting-IP` unless you set `CF_CONNECTING_IP='$http_cf_connecting_ip'` in `.env` (the
+ single quotes stop Compose from expanding it to an empty string), which is correct only with
+ Cloudflare genuinely in front. Before that it appended to `X-Forwarded-For` and
passed `CF-Connecting-IP` straight through, and the API reads the first entry — so any caller
could choose the address recorded against it. Never the browser's user-agent,
and never the passkey id behind a failed sign-in — that id is a stable
diff --git a/docker-compose.yml b/docker-compose.yml
index 2f0d9b6a0..805361f6b 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -55,7 +55,8 @@ services:
# Docker's embedded DNS. Only ever needs changing on a runtime that is not Docker.
- RESOLVER=${RESOLVER:-127.0.0.11}
# Empty drops the CF-Connecting-IP header, so a direct client cannot forge the address
- # the activity log records. Cloudflare users set CF_CONNECTING_IP=$$http_cf_connecting_ip.
+ # the activity log records. Cloudflare users set CF_CONNECTING_IP='$http_cf_connecting_ip'
+ # in .env, single quotes included, or Compose expands it to an empty string.
- CF_CONNECTING_IP=${CF_CONNECTING_IP:-}
# Subpath deployments behind a proxy that passes its prefix through ("/gym", no trailing
# slash). Empty serves the app at the site root, which is what it has always done; a proxy