cobalt notes from a small home lab

Nginx as a plain static host: the whole config

This site is a directory of HTML files and a config that fits on one screen. I keep reinventing this every couple of years, so here it is for the next time.

server {
    listen 443 ssl http2;
    server_name example.org;
    ssl_certificate     /etc/letsencrypt/live/example.org/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.org/privkey.pem;
    root /var/www/site;
    index index.html;
    error_page 404 /404.html;
    location / { try_files $uri $uri/ $uri.html =404; }
    gzip on;
    gzip_types text/css application/javascript image/svg+xml;
}

The $uri.html in try_files is what gives clean URLs without a rewrite rule. /notes/foo serves notes/foo.html. That's the whole trick.

Certificates come from certbot with the standalone authenticator and a pre/post hook that stops and starts nginx for the thirty seconds it needs port 80. The nginx plugin is nicer, but standalone has never once failed on me, and the plugin has.

Turn off server_tokens. Nobody needs the version number in the headers.