2026-10-09 21:29:59 +07:00
|
|
|
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;
|
|
|
|
|
}
|
2026-10-22 09:55:21 +07:00
|
|
|
|
2026-10-23 22:34:23 +07:00
|
|
|
# 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.
|
2026-10-22 09:55:21 +07:00
|
|
|
location /api/content/ {
|
|
|
|
|
auth_basic "Editor";
|
|
|
|
|
auth_basic_user_file /etc/nginx/htpasswd;
|
|
|
|
|
|
2026-10-23 22:34:23 +07:00
|
|
|
proxy_pass ${GITEA_CONTENTS_API};
|
2026-10-22 09:55:21 +07:00
|
|
|
proxy_ssl_server_name on;
|
|
|
|
|
proxy_set_header Authorization "token ${GITEA_TOKEN}";
|
|
|
|
|
}
|
2026-10-09 21:29:59 +07:00
|
|
|
}
|