# nginx config for serving a built Docusaurus site.
#
# Docusaurus emits static .html files. This config:
#  - serves gzip-compressed assets,
#  - resolves "clean" URLs (/docs/intro → /docs/intro/index.html or intro.html),
#  - falls back to Docusaurus's own 404 page for unknown paths.

server {
    listen       80;
    server_name  _;

    root   /usr/share/nginx/html;
    index  index.html;

    # Issue relative redirects so the trailing-slash redirect (/blog → /blog/)
    # keeps the caller's host, scheme, and port — correct behind any reverse
    # proxy or non-80 port mapping.
    absolute_redirect off;

    # Long-cache the fingerprinted assets Docusaurus generates
    location /assets/ {
        expires 1y;
        add_header Cache-Control "public, immutable";
    }

    # Serve Docusaurus's branded 404 page, but with a real 404 status code
    # (not a soft-404) so crawlers and monitors see the correct response.
    error_page 404 /404.html;

    # Clean-URL resolution
    location / {
        try_files $uri $uri/ $uri.html =404;
    }

    # Basic gzip
    gzip            on;
    gzip_types      text/plain text/css application/javascript application/json image/svg+xml;
    gzip_min_length 1024;
}
