# ASW Nginx Directory Listing — config snippet # # nginx's autoindex generates its own HTML that can't be easily replaced. # The cleanest approach: serve autoindex JSON and render it client-side. # # This gives full control over the HTML output while keeping nginx doing # the work of listing directories. # ── Option A: JSON autoindex + client-side renderer (recommended) ───────────── # # nginx serves directory listings as JSON; a small JS fragment renders them # with ASW styles. The renderer is served from /asw/autoindex.js. location /files/ { # The directory to browse alias /var/www/files/; autoindex on; autoindex_format json; # nginx ≥ 1.7.9 # When the path ends in / (directory request), serve our renderer # instead of the raw JSON. The renderer fetches the JSON itself. index ___nonexistent___; # disable default index file lookup # Intercept directory responses and redirect to renderer # (requires auth_request or a small proxy; see Option B for simpler approach) } # Serve the ASW autoindex renderer location = /asw/autoindex.js { alias /home/exedev/projects/agentic-semantic-web/packs/nginx/autoindex.js; } # ── Option B: add_before_body / add_after_body (simplest) ──────────────────── # # nginx injects HTML before and after its generated listing. # This wraps the ugly default output in ASW chrome — not perfect but zero JS. # # Requires nginx built with --with-http_addition_module (default on most distros). location /browse/ { alias /var/www/browse/; autoindex on; # Inject ASW nav before the listing, footer after add_before_body /asw/autoindex-header.html; add_after_body /asw/autoindex-footer.html; } location = /asw/autoindex-header.html { alias /home/exedev/projects/agentic-semantic-web/packs/nginx/autoindex-header.html; internal; } location = /asw/autoindex-footer.html { alias /home/exedev/projects/agentic-semantic-web/packs/nginx/autoindex-footer.html; internal; }