Update force-ssl.conf

Revised as per PR discussion.
This commit is contained in:
EDIflyer 2024-06-11 07:59:38 +01:00 committed by GitHub
parent 2d65d672c8
commit 2bb99e68d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,16 +2,9 @@ set $test "";
if ($scheme = "http") { if ($scheme = "http") {
set $test "H"; set $test "H";
} }
if ($request_uri ~ "^\/\.well-known\/acme-challenge\/(.*)" { if ($request_uri ~ "^\/\.well-known\/acme-challenge\/(.*)") {
set $test "${test}T"; set $test "${test}T";
} }
if ($test = H) { if ($test = H) {
return 301 https://$host$request_uri; return 301 https://$host$request_uri;
} }
if ($request_uri !~ "^\/\.well-known\/acme-challenge\/(.*)") {
set $FORCE "${FORCE}D";
}
# If we are http and outside the LetsEncrypt directories redirect to https via 301
if ($FORCE = HD) {
return 301 https://$host$request_uri;
}