This commit is contained in:
Dallas Lu 2026-06-09 14:41:15 +08:00
parent c50569d73e
commit a624163120
No known key found for this signature in database
27 changed files with 215 additions and 6 deletions

View file

@ -1,9 +1,14 @@
set $root_domain "";
# Derive the apex domain from a www-prefixed primary server_name. This keeps the
# snippet simple, but it also means callers should not use it on multi-name
# server blocks whose first name is not the canonical www host.
if ($server_name ~* ^www\.(?<apex_domain>.+)$) {
set $root_domain $apex_domain;
}
# Use 307 so POST and other non-GET methods keep their method during
# canonicalization instead of being rewritten to GET as with many 301/302 flows.
if ($host = $root_domain) {
return 307 $scheme://$server_name$request_uri;
}