This repository was archived by the owner on May 22, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathnginx.conf
More file actions
49 lines (43 loc) · 1.96 KB
/
Copy pathnginx.conf
File metadata and controls
49 lines (43 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# nginx.conf — LME Docs production server
#
# @decision DEC-005
# @title nginx SPA routing with try_files and 1-year asset caching
# @status accepted
# @rationale Docusaurus generates a single-page application where client-side
# routing handles most navigation. nginx must fall back to
# index.html (or the nearest index.html) for any path not found
# on disk. Static assets (JS, CSS, images, fonts) are content-
# addressed (hashed filenames) so safe to cache for 1 year.
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# ── SPA / Docusaurus routing ──────────────────────────────────────
# 1. Try the exact file path
# 2. Try the path as a directory (serving its index.html)
# 3. Try appending .html (Docusaurus generates foo.html alongside foo/)
# 4. Return 404 (nginx will serve the 404.html below)
location / {
try_files $uri $uri/ $uri.html =404;
}
# ── Custom 404 page ───────────────────────────────────────────────
error_page 404 /404.html;
location = /404.html {
internal;
}
# ── Long-lived cache for hashed static assets ─────────────────────
# Docusaurus content-addresses all JS/CSS/image assets with a hash in
# the filename, so it is safe to cache them aggressively for 1 year.
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|webp|avif)$ {
expires 1y;
add_header Cache-Control "public, immutable";
access_log off;
}
# ── Health check endpoint (for container orchestrators) ───────────
location /healthz {
return 200 "ok\n";
add_header Content-Type text/plain;
access_log off;
}
}