From 1ba378b632adecb16e85cf5f6eb7088208708409 Mon Sep 17 00:00:00 2001 From: Georgiy Sitnikov Date: Fri, 14 Aug 2026 12:11:38 +0200 Subject: [PATCH] - Enable Templating feature as per https://hub.docker.com/_/nginx#using-environment-variables-in-nginx-configuration-new-in-119 - Set default Variables Solution for https://github.com/DuarteSantos8/openGym/issues/99 --- README.md | 3 +++ web/Dockerfile | 8 +++++++- web/{nginx.conf => nginx.conf.template} | 4 ++-- 3 files changed, 12 insertions(+), 3 deletions(-) rename web/{nginx.conf => nginx.conf.template} (94%) diff --git a/README.md b/README.md index 4da510b..7afbf24 100644 --- a/README.md +++ b/README.md @@ -152,6 +152,9 @@ All via `.env` (see `.env.example`): | `RP_ID` | Hostname passkeys are bound to | `localhost` | | `ORIGIN` | Full URL the app is served from | `http://localhost:8080` | | `WEB_PORT` | Host port for the web UI | `8080` | +| `NGINX_PORT` | Internal Nginx port for the web UI | `80` | +| `BACKEND` | Backend Service service name, so that API calls can be forwarded to | `api` | +| `PORT` | Port for the api backend Service | `3000` | | `RP_NAME` | Name shown in the passkey prompt | `openGym` | | `ADMIN_UIDS` | User ids that get the admin dashboard (comma-separated) | *(none)* | | `INVITE_ONLY` | Require an invite code to create a profile | *(off)* | diff --git a/web/Dockerfile b/web/Dockerfile index 9b30e63..ba21610 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -15,6 +15,12 @@ COPY frontend/ ./ RUN npm run build FROM nginx:alpine -COPY web/nginx.conf /etc/nginx/conf.d/default.conf +COPY web/nginx.conf.template /etc/nginx/templates/default.conf.template COPY --from=build /app/dist /usr/share/nginx/html # exercise media (img/gif) is mounted at runtime from the media volume + +# Set Default ENVs for nginx +ENV NGINX_PORT=80 +ENV BACKEND=api +ENV PORT=3000 + diff --git a/web/nginx.conf b/web/nginx.conf.template similarity index 94% rename from web/nginx.conf rename to web/nginx.conf.template index 505c16f..f8d67e6 100644 --- a/web/nginx.conf +++ b/web/nginx.conf.template @@ -1,13 +1,13 @@ # openGym — standalone web server: serves the static app AND proxies /api to the backend, # so the whole app lives on ONE origin (required for WebAuthn / passkeys). server { - listen 80; + listen ${NGINX_PORT}; root /usr/share/nginx/html; index index.html; # API → backend container location /api/ { - proxy_pass http://api:3000; + proxy_pass http://${BACKEND}:${PORT}; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr;