import ngx from "jsr:@char/ngx@0.2.2"; const DOMAIN = "chordpad.vibed.software" const ROOT = "/srv/www/chordpad.vibed.software/dist" export const config = ngx(undefined, [ ngx("server", [ [ngx.serverName(DOMAIN), "listen 80", "listen [::]:80"], [`return 301 https://$host$request_uri`], ]), ngx("server", [ [ngx.serverName(DOMAIN), ...ngx.listen(), ...ngx.letsEncrypt(DOMAIN)], [`root ${ROOT}`, "index index.html"], ["gzip on", "gzip_types text/css application/javascript image/svg+xml"], // vite names these by their contents, so a name never means anything else ngx("location /assets/", [ 'add_header Cache-Control "public, max-age=31536000, immutable"', "try_files $uri =404", ]), // but the page always gets checked, so it doesn't point at a previous build's assets ngx("location = /index.html", ['add_header Cache-Control "no-cache"']), ngx("location /", ["try_files $uri /index.html"]), // TheoryTab pages can't be read cross-origin, so imports fetch them through here (vite's dev // server does the same). only song pages, and only reading them ngx("location /hooktheory/theorytab/view/", [ ngx("limit_except GET", ["deny all"]), [ "proxy_pass https://www.hooktheory.com/theorytab/view/", "proxy_set_header Host www.hooktheory.com", // hooktheory sits behind cloudflare, which needs the name to pick a certificate "proxy_ssl_server_name on", 'proxy_set_header Cookie ""', ], ]), ]), ]); if (import.meta.main) { console.log(config.build()); }