server {
  listen 80;
  server_name _;
  root /usr/share/nginx/html;
  index index.html;

  # 1) Mappa MIME standard (html, css, js, png, svg, ecc.)
  include /etc/nginx/mime.types;

  # 2) CORS opzionali
  add_header Access-Control-Allow-Origin "*" always;
  add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Range" always;
  add_header Access-Control-Allow-Methods "GET, HEAD, OPTIONS" always;

  # 3) Statici in webroot
  location / {
    try_files $uri $uri/ =404;
  }

  # 4) Alias per i dati fuori webroot (PMTiles in /data)
  #    ^~ => questa location ha la precedenza sui regex match, es. \.pmtiles$
  location ^~ /data/ {
    alias /data/;
    # Solo qui: tipi per .pmtiles + header "Accept-Ranges"
    types { application/octet-stream pmtiles; }
    add_header Accept-Ranges "bytes" always;
  }

  # 5) (Opzionale) .pmtiles sotto webroot
  location ~ \.pmtiles$ {
    types { application/octet-stream pmtiles; }
    add_header Accept-Ranges "bytes" always;
  }
}