thestub

Serving a static site with nginx

2026-05-03

This site is just a directory of hand-written HTML. No build step, no JavaScript, no analytics. nginx serves it and gets out of the way.

server {
    listen 80;
    server_name example.org;
    root /var/www/html;
    index index.html;
    location / { try_files $uri $uri/ $uri.html =404; }
    error_page 404 /404.html;
}

The try_files line gives clean URLs without renaming anything. Certificates come from Let's Encrypt and renew on their own; the only thing I check is that the renewal timer is still enabled after upgrades.

← All notes