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): Basic-auth at the proxy, the Gitea # write token lives only in the container environment (${GITEA_TOKEN} is # substituted by the image's envsubst template step — the SPA bundle never # carries a write-capable token). location /api/content/ { auth_basic "Editor"; auth_basic_user_file /etc/nginx/htpasswd; proxy_pass https://code.vugado.com/api/v1/repos/dong.nguyen/cv/contents/; proxy_ssl_server_name on; proxy_set_header Host code.vugado.com; proxy_set_header Authorization "token ${GITEA_TOKEN}"; } }