summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVoid Agent <void@jayrup.hermes>2026-10-22 23:15:41 +0100
committerVoid Agent <void@jayrup.hermes>2026-10-22 23:15:41 +0100
commitc7a31a36f25f659e9ad7fa745a104fa993420f46 (patch)
treee2a6646885792e47d2993d6a842dbe0c7f69c937
parent0eea672450447fc678f8073307a2e9139dd85616 (diff)
nginx: keep an explicit .txt location so /robots.txt works for curl
Dropping the .txt location made the curl/wget suffix map apply to every request, so /robots.txt was looked up as /robots.txt.txt and 404'd. Keep the location, but without add_header, so mime.types and charset cover the type and the server-level security headers are still inherited.
-rw-r--r--nginx.conf8
1 files changed, 8 insertions, 0 deletions
diff --git a/nginx.conf b/nginx.conf
index a7e345a..d8a15ca 100644
--- a/nginx.conf
+++ b/nginx.conf
@@ -89,6 +89,14 @@ server {
=404;
}
+ # Direct .txt requests must bypass the curl/wget suffix map, otherwise a
+ # request for /robots.txt is looked up as /robots.txt.txt. No add_header
+ # here: mime.types supplies text/plain, `charset` supplies the charset, so
+ # the server-level security headers are inherited normally.
+ location ~* \.txt$ {
+ try_files $uri =404;
+ }
+
location / {
try_files
$uri$final_suffix