web: fix resolution of external links to static eh page

This commit is contained in:
Christoph Schindlbeck 2026-08-08 13:37:32 +02:00 committed by Christoph Schindlbeck
commit a75d22edf5

View file

@ -24,6 +24,13 @@ server {
return 301 https://eh21.easterhegg.eu$request_uri;
}
}
# Compute the exported filename from the doku.php ?id= argument.
map $arg_id $doku_file {
default /$arg_id.html; # id=faq -> /faq.html
"" /start.html; # /doku.php (no id) -> start
"~\.\." /__deny__; # block ../ traversal -> 404
"~^(?<ns>[^:]+):(?<pg>.+)$" /${ns}_${pg}.html; # id=user:sos -> /user_sos.html
}
server {
listen 443 ssl http2;
@ -50,9 +57,24 @@ server {
index cryptomug.html;
try_files $uri $uri/ =404;
}
# Homepage: original "/" was the "start" page (skips the index.html meta-refresh)
location = / {
try_files /start.html =404;
}
# Old DokuWiki permalinks: /doku.php?id=<pageid> (rev=/do= are ignored -> current page)
location = /doku.php {
try_files $doku_file =404;
}
# Namespaced clean URLs: colon separator became "_" in the filenames
# /user:sos -> /user_sos.html /wiki:syntax -> /wiki_syntax.html
location ~ "^/(?<ns>[^/:]+):(?<page>[^/:]+)/?$" {
try_files /${ns}_${page}.html =404;
}
location / {
try_files $uri $uri/ =404;
try_files $uri $uri.html =404;
}
}