generate redirect for ever virtualhost
This commit is contained in:
parent
86ae8197b5
commit
599f0803a1
1 changed files with 107 additions and 102 deletions
|
|
@ -122,22 +122,26 @@
|
||||||
prev: name:
|
prev: name:
|
||||||
let
|
let
|
||||||
cfg = self.nixosConfigurations.${name}.config;
|
cfg = self.nixosConfigurations.${name}.config;
|
||||||
in
|
vhosts = builtins.attrNames cfg.services.nginx.virtualHosts;
|
||||||
prev
|
address =
|
||||||
// {
|
|
||||||
"${name}" = {
|
|
||||||
dest =
|
|
||||||
(builtins.head
|
(builtins.head
|
||||||
# dieser ausdruck ermittelt den interface namen und die ipv4 addresse als redirect ziel
|
# dieser ausdruck ermittelt den interface namen und die ipv4 addresse als redirect ziel
|
||||||
cfg.networking.interfaces.${builtins.head (builtins.attrNames cfg.networking.interfaces)}.ipv4.addresses
|
cfg.networking.interfaces.${builtins.head (builtins.attrNames cfg.networking.interfaces)}.ipv4.addresses
|
||||||
).address;
|
).address;
|
||||||
# bisher wird ein redirect für den ersten virtualHost generiert
|
in
|
||||||
# TODO rediret für jeden virtualHost
|
prev
|
||||||
domain = builtins.head (builtins.attrNames cfg.services.nginx.virtualHosts);
|
// (builtins.foldl' (
|
||||||
|
val: vhost:
|
||||||
|
val
|
||||||
|
// {
|
||||||
|
"${vhost}" = {
|
||||||
|
dest = address;
|
||||||
|
domain = vhost;
|
||||||
httpsPort = 443;
|
httpsPort = 443;
|
||||||
httpPort = 80;
|
httpPort = 80;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
) { } vhosts)
|
||||||
)
|
)
|
||||||
{ }
|
{ }
|
||||||
(
|
(
|
||||||
|
|
@ -229,7 +233,8 @@
|
||||||
# pro domain wird ein backend festgelegt und auf https redirected wenn es keine acme request ist
|
# pro domain wird ein backend festgelegt und auf https redirected wenn es keine acme request ist
|
||||||
${lib.foldlAttrs (
|
${lib.foldlAttrs (
|
||||||
prev: name: value:
|
prev: name: value:
|
||||||
prev + ''
|
prev
|
||||||
|
+ ''
|
||||||
use_backend ${name}_80 if is_${name}
|
use_backend ${name}_80 if is_${name}
|
||||||
http-request redirect scheme https code 301 if !is_acme is_${name}
|
http-request redirect scheme https code 301 if !is_acme is_${name}
|
||||||
''
|
''
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue