mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-12 04:35:41 +03:00
Tweak nginx config for Let's Encrypt ACME challenges
Currently, this is using a "URI prefix match", but per nginx docs,
```
[...] the location with the longest matching prefix is selected and remembered. Then regular expressions are checked, in the order of their appearance in the configuration file. The search of regular expressions terminates on the first match, and the corresponding configuration is used. If no match with a regular expression is found then the configuration of the prefix location remembered earlier is used.
```
which means a config like this (from wordpress service) will override that
```
locations = {
"~ /\\." = {
priority = 800;
extraConfig = "deny all;";
};
};
```
😱
Luckily, from nginx docs:
```
If the longest matching prefix location has the “^~” modifier then regular expressions are not checked.
```
Whew!
This commit is contained in:
parent
bbbaaa3e35
commit
1a73877305
1 changed files with 4 additions and 1 deletions
|
@ -275,7 +275,10 @@ let
|
|||
redirectListen = filter (x: !x.ssl) defaultListen;
|
||||
|
||||
acmeLocation = optionalString (vhost.enableACME || vhost.useACMEHost != null) ''
|
||||
location /.well-known/acme-challenge {
|
||||
# Rule for legitimate ACME Challenge requests (like /.well-known/acme-challenge/xxxxxxxxx)
|
||||
# We use ^~ here, so that we don't check any regexes (which could
|
||||
# otherwise easily override this intended match accidentally).
|
||||
location ^~ /.well-known/acme-challenge/ {
|
||||
${optionalString (vhost.acmeFallbackHost != null) "try_files $uri @acme-fallback;"}
|
||||
${optionalString (vhost.acmeRoot != null) "root ${vhost.acmeRoot};"}
|
||||
auth_basic off;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue