Files
server-infra/roles/web-static/templates/nginx.conf.j2
T
westfarnandCursor dce0879e62 Serve Hesychia crawler files as static text instead of the app shell.
Exact locations return robots.txt, sitemap.xml, and llms.txt, or 404.
Closes #43.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-17 07:19:05 -05:00

67 lines
1.8 KiB
Django/Jinja

# Managed by Ansible (roles/web-static). Do not edit by hand.
# Access logs: JSON to stdout for Alloy → Loki (see dta_webapp/deploy/nginx-logging.conf).
log_format observability escape=json
'{'
'"timestamp":"$time_iso8601",'
'"level":"INFO",'
'"service":"$obs_app",'
'"app":"$obs_app",'
'"env":"$obs_env",'
'"message":"$request",'
'"method":"$request_method",'
'"status":$status,'
'"bytes":$body_bytes_sent,'
'"request_time":$request_time,'
'"uri":"$request_uri",'
'"remote_addr":"$remote_addr",'
'"user_agent":"$http_user_agent"'
'}';
{% for a in _static_apps %}
server {
listen {{ a.port }};
server_name _;
set $obs_app "{{ a.name }}";
set $obs_env "{{ a.env }}";
access_log /dev/stdout observability;
error_log /dev/stderr warn;
root {{ (app_catalog[a.name].webroot_pattern | default(web_static_root ~ '/{env}_' ~ a.name)) | replace('{env}', a.env) }};
index index.html;
{% if app_catalog[a.name].exact_root_files | default(false) %}
# Crawlers must get these files, never the SPA index.html fallback.
location = /robots.txt {
default_type text/plain;
try_files /robots.txt =404;
}
location = /sitemap.xml {
default_type application/xml;
try_files /sitemap.xml =404;
}
location = /llms.txt {
default_type text/plain;
try_files /llms.txt =404;
}
{% endif %}
{% if app_catalog[a.name].error_page_404 | default('') %}
error_page 404 {{ app_catalog[a.name].error_page_404 }};
location / {
try_files $uri $uri/ =404;
}
{% else %}
location / {
try_files $uri $uri/ /index.html;
}
{% endif %}
location ~* \.(?:js|css|woff2?|png|jpg|jpeg|gif|svg|ico)$ {
expires 7d;
add_header Cache-Control "public";
}
}
{% endfor %}