Files
cv/nginx.conf
T
dong.nguyen 83da513931 perf(edit): load the draft documents as one concurrent wave
EditModeShell issued the 12 draft documents with a for-loop of awaits, then the
2 category-label files. It now starts two concurrent requests whose success and
failure handlers are attached in the same tick, so a label rejection landing
while the documents are still in flight is not an unhandled rejection. The two
failure branches are unchanged: a document failure is the offline state, a label
failure only disables the category rule. Measured through the dev proxy, the
same transport the app uses: 12 documents sequential 902 ms -> 210 ms for the
whole 14-request wave, 38768 bytes and 12 distinct payloads byte-identical to
the sequential loop.

nginx.conf now proxies /api/content/ to Gitea over HTTP/2 (proxy_http_version 2
+ a cleared Connection header), so the wave rides one pooled upstream connection
instead of one HTTP/1.1 connection per in-flight request. The stack's nginx
1.31.x already does HTTP/1.1 with upstream keepalive caching by default since
1.29.7, so no upstream block is declared and the envsubst contract is
untouched; the pipeline's test-before-touch nginx -t is what proves the image
accepts proxy_http_version 2.

Specs: spec-v4-live-edit.md row 25 + the draft-initialization bullet,
spec-v4-deploy-infra.md D14 + row 10, AGENTS.md nginx.conf line.
2026-10-24 14:45:26 +07:00

65 lines
2.1 KiB
Nginx Configuration File

server {
listen 80;
listen [::]:80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# React/Vue/Vite SPA routing
location / {
try_files $uri $uri/ /index.html;
}
# Do not aggressively cache index.html.
# It references the latest hashed JS/CSS files.
location = /index.html {
try_files $uri =404;
add_header Cache-Control "no-cache, must-revalidate";
}
# Vite-generated assets normally contain content hashes.
# They can safely be cached for a long time.
location ~* \.(?:css|js|mjs|map|png|jpg|jpeg|gif|svg|ico|webp|avif|woff|woff2|ttf|otf)$ {
try_files $uri =404;
expires 30d;
add_header Cache-Control "public, max-age=2592000, immutable";
}
location = /favicon.ico {
access_log off;
log_not_found off;
}
location = /robots.txt {
access_log off;
log_not_found off;
}
# Content write path (spec-v4 §6.2, spec-v4-deploy-infra D11/D13): Basic-auth
# at the proxy; ${GITEA_TOKEN} and ${GITEA_CONTENTS_API} are substituted by
# the image's envsubst template step from the container environment (sourced
# from the stack's secrets/site_config) — the SPA bundle and the repository
# never carry the token or the Gitea host.
location /api/content/ {
auth_basic "Editor";
auth_basic_user_file /etc/nginx/htpasswd;
# HTTP/2 to the upstream (nginx >= 1.29.4; the stack runs 1.31.x). The
# edit-mode client issues its 12 document reads + 2 label reads as one
# concurrent wave, and the Gitea host answers h2, so those requests
# multiplex over a single upstream connection instead of one HTTP/1.1
# connection each. Upstream keepalive caching is already the default
# since 1.29.7; the docs still require the Connection header to be
# cleared for a reused upstream connection.
proxy_http_version 2;
proxy_set_header Connection "";
proxy_pass ${GITEA_CONTENTS_API};
proxy_ssl_server_name on;
proxy_set_header Authorization "token ${GITEA_TOKEN}";
}
}