Web server — nginx (nginx.service)

Install Nginx:

sudo apt install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx

Site configs live in /etc/nginx/sites-available/ and are enabled by a symlink in sites-enabled/.

SiteListens onRootReached via
default:80/var/www/htmlLAN (stock page)
notes:<NOTES_PORT>/var/www/notesLAN + tailnet
song-rating127.0.0.1:<SONG_PORT>/var/www/song_ratingTailscale Serve (HTTPS) only

notes

server {
    listen <NOTES_PORT>;
    listen [::]:<NOTES_PORT>;
    server_name _;
 
    root /var/www/notes;
    index index.html;
 
    add_header X-Content-Type-Options "nosniff" always;
    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header Referrer-Policy "strict-origin-when-cross-origin" always;
    add_header X-Robots-Tag "noindex, nofollow" always;
 
    location ~ /\. { deny all; }                      # block .git etc.
 
    location / {
        try_files $uri $uri.html $uri/ =404;          # clean URLs (no .html)
    }
 
    error_page 404 /404.html;                         # Quartz generates this page
}

song-rating

server {
    listen 127.0.0.1:<SONG_PORT>;                     # localhost only
    root /var/www/song_rating;
    index index.html;
 
    add_header Cache-Control "no-cache";              # PWA picks up updates
 
    location ~ /\. { deny all; }
    location /deploy/ { deny all; }
 
    location = /manifest.webmanifest {
        types { application/manifest+json webmanifest; }
    }
 
    # Pass-through proxy to the iTunes Search API (avoids browser CORS)
    location /itunes/ {
        resolver 1.1.1.1 8.8.8.8 valid=300s ipv6=off;
        set $itunes_host itunes.apple.com;
        rewrite ^/itunes/(.*)$ /$1 break;
        proxy_pass https://$itunes_host;
        proxy_set_header Host $itunes_host;
        proxy_set_header User-Agent "SongRatings";
        proxy_set_header Cookie "";
        proxy_set_header Referer "";
        proxy_ssl_server_name on;
    }
}

Bound to localhost, so the LAN can’t reach it directly. 07 - Tailscale Serve proxies it over HTTPS.

Commands

sudo ln -s /etc/nginx/sites-available/<site> /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
ls -l /etc/nginx/sites-enabled/

Back: 00 - Overview