Deploy path: give the health ingest 32 MB, and stop appending to X-Forwarded-For
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
gym.dploy.lol does not run docker-compose.yml. It runs deploy/compose-build-at-deploy.yml, where nginx is generated inline by the web service from a printf in its command, with a single global `client_max_body_size 5m`. The per-route 32 MB added for the Apple Health ingest lives in web/nginx.conf.template, which belongs to the registry-image path and is never read here — so a first export of more than 5 MB came back as nginx's own 413 HTML before the API saw a byte of it. That path now has a second location for /api/vitals/ingest with 32m; nginx picks the longest matching prefix, so that one route takes the bigger body and everything else keeps matching the API's MAX_BODY. Both limits are spelled out in comment 3 at the top, with a note that the two deployment shapes have to be changed together. Also fixes a smaller thing found while reading it: X-Forwarded-For was $proxy_add_x_forwarded_for, which APPENDS to whatever the client sent, and the API reads the first entry — so a caller could choose the address recorded about it. It is now $remote_addr, which is what web/nginx.conf.template already does and for the same reason documented there. Audit IPs are off by default, so nothing was being recorded; this matters the day somebody sets AUDIT_IP=net. Comment 3 also now records the two things that make a deploy confusing rather than broken: the api service copies the clone into /app at container start, so an api that was not recreated keeps serving the previous revision while web-build serves the new frontend (exactly the 404-on-a-new-route symptom), and web resolves api's IP once at start-up, so recreating api without web leaves nginx pointing at a dead address and every /api call answering 502.
This commit is contained in:
1 parent
8d190bb591
commit
ba37ef8a44
1 file changed
+20
-5
@@ -22,10 +22,19 @@
|
||||
# `docker compose down -v` — `-v` deletes the volumes, which is every logged set and every
|
||||
# weigh-in. A plain `docker compose down` is safe. Check yours with `docker volume ls`.
|
||||
#
|
||||
# 3. nginx needs `client_max_body_size`. Its default request limit is 1 MB, and the app PUTs
|
||||
# the whole profile to /api/data on every change — a couple of years of training passes 1 MB
|
||||
# and the sync then fails with a 413 the UI cannot explain. web/nginx.conf.template in the
|
||||
# repository sets 5m, and the API's own MAX_BODY is 5 MB; this matches both.
|
||||
# 3. nginx needs `client_max_body_size`, and needs it in two sizes. Its default request limit is
|
||||
# 1 MB, and the app PUTs the whole profile to /api/data on every change — a couple of years of
|
||||
# training passes 1 MB and the sync then fails with a 413 the UI cannot explain. So the bulk
|
||||
# of /api is 5m, matching the API's own MAX_BODY. But the Apple Health ingest takes whole
|
||||
# exports: a first sync of a year of raw samples is tens of megabytes, and the API allows
|
||||
# that one route 32 MB (VITALS_MAX_BODY in api/server.js). One global number cannot do both,
|
||||
# which is why the generated config below has a second location for that one path — nginx
|
||||
# picks the longest matching prefix, so /api/vitals/ingest gets 32m and everything else keeps
|
||||
# 5m.
|
||||
#
|
||||
# This inline config is the one this deployment actually runs; web/nginx.conf.template is for
|
||||
# the registry-image path (docker-compose.yml) and is NOT read here. A change to the limits
|
||||
# has to be made in both, or the two deployment shapes diverge.
|
||||
#
|
||||
# To deploy a change to the code, force the one-shot services to run again — `source` and
|
||||
# `web-build` have `restart: "no"`, so compose leaves them alone when their configuration has not
|
||||
@@ -33,6 +42,12 @@
|
||||
#
|
||||
# docker compose up -d --force-recreate
|
||||
#
|
||||
# That is also how the `api` service picks up new code: it copies the clone into /app at container
|
||||
# start, so an `api` that was not recreated keeps running the previous revision while `web-build`
|
||||
# happily serves the new frontend. Recreate `web` in the same command, and not on its own: its
|
||||
# `proxy_pass http://api:3000` is resolved once at start-up, so a recreated api means a new IP and
|
||||
# an nginx still pointing at the old one answers 502 on every /api call.
|
||||
#
|
||||
# Set RP_ID, RP_NAME and ORIGIN in the host's environment (or its .env). RP_ID must be the exact
|
||||
# hostname the app is served from — passkeys are bound to it — and RP_NAME is what the passkey
|
||||
# prompt shows, so set it to KuentaGYM.
|
||||
@@ -132,7 +147,7 @@ services:
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- "printf 'server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; client_max_body_size 5m; location /api/ { proxy_pass http://api:3000; proxy_http_version 1.1; 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 / { try_files $$uri $$uri/ /index.html; } }' > /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'"
|
||||
- "printf 'server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; client_max_body_size 5m; location /api/vitals/ingest { client_max_body_size 32m; proxy_pass http://api:3000; proxy_http_version 1.1; proxy_set_header Host $$host; proxy_set_header X-Real-IP $$remote_addr; proxy_set_header X-Forwarded-For $$remote_addr; proxy_set_header X-Forwarded-Proto $$scheme; } location /api/ { proxy_pass http://api:3000; proxy_http_version 1.1; proxy_set_header Host $$host; proxy_set_header X-Real-IP $$remote_addr; proxy_set_header X-Forwarded-For $$remote_addr; proxy_set_header X-Forwarded-Proto $$scheme; } location / { try_files $$uri $$uri/ /index.html; } }' > /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'"
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
|
||||
Reference in new issue
Block a user