forked from emily/nixfiles
49 lines
1.2 KiB
Nix
49 lines
1.2 KiB
Nix
|
let
|
||
|
extraConfig = ''
|
||
|
add_header Referrer-Policy "same-origin" always;
|
||
|
'';
|
||
|
func = builtins.mapAttrs (vhostName: vhostCfg:
|
||
|
let
|
||
|
def = {
|
||
|
forceSSL = true;
|
||
|
http3 = true;
|
||
|
quic = true;
|
||
|
};
|
||
|
conf = if builtins.hasAttr "redirectTo" vhostCfg
|
||
|
then {
|
||
|
useACMEHost = vhostCfg.redirectTo;
|
||
|
globalRedirect = vhostCfg.redirectTo;
|
||
|
}
|
||
|
else if builtins.hasAttr "ACMEHost" vhostCfg
|
||
|
then {
|
||
|
useACMEHost = vhostCfg.ACMEHost;
|
||
|
root = vhostCfg.webroot;
|
||
|
}
|
||
|
else {
|
||
|
enableACME = true;
|
||
|
root = vhostCfg.webroot;
|
||
|
};
|
||
|
otherCfg = (builtins.removeAttrs vhostCfg [ "redirectTo" "ACMEHost" "webroot" "extraConfig" ] // (
|
||
|
if builtins.hasAttr "extraConfig" vhostCfg
|
||
|
then { extraConfig = ''${vhostCfg.extraConfig} ${extraConfig}''; }
|
||
|
else { inherit extraConfig; }
|
||
|
));
|
||
|
in
|
||
|
conf // def // otherCfg
|
||
|
);
|
||
|
in {
|
||
|
test = func {
|
||
|
"www.miau.zip" = {
|
||
|
redirectTo = "miau.zip";
|
||
|
};
|
||
|
"miau.zip" = {
|
||
|
ACMEHost = "miau.zip";
|
||
|
webroot = "/skgj";
|
||
|
locations."/".extraConfig = "fsfs";
|
||
|
extraConfig = ''
|
||
|
skfdsjf
|
||
|
'';
|
||
|
};
|
||
|
};
|
||
|
}
|