mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 12:29:19 -08:00
refactor(nginx): proxy options
This commit is contained in:
parent
c3f3fe1fed
commit
02508ecbd3
18 changed files with 638 additions and 424 deletions
|
|
@ -6,6 +6,7 @@
|
|||
}: let
|
||||
inherit (lib.modules) mkDefault;
|
||||
inherit (config.services) nginx;
|
||||
cfg = config.services.unifi;
|
||||
in {
|
||||
config.services.nginx = {
|
||||
virtualHosts = let
|
||||
|
|
@ -13,24 +14,34 @@ in {
|
|||
proxy_redirect off;
|
||||
proxy_buffering off;
|
||||
'';
|
||||
locations = {
|
||||
"/" = {
|
||||
proxy.enable = true;
|
||||
};
|
||||
"/wss/" = {
|
||||
proxy = {
|
||||
enable = true;
|
||||
websocket.enable = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
name.shortServer = mkDefault "unifi";
|
||||
kTLS = mkDefault true;
|
||||
in {
|
||||
unifi = {
|
||||
inherit name extraConfig kTLS;
|
||||
inherit name extraConfig kTLS locations;
|
||||
vouch.enable = mkDefault true;
|
||||
ssl.force = mkDefault true;
|
||||
locations."/" = {
|
||||
proxyPass = mkDefault (access.proxyUrlFor { serviceName = "unifi"; portName = "management"; });
|
||||
};
|
||||
proxy.url = mkDefault (if cfg.enable
|
||||
then "https://localhost:8443"
|
||||
else access.proxyUrlFor { serviceName = "unifi"; portName = "management"; }
|
||||
);
|
||||
};
|
||||
unifi'local = {
|
||||
inherit name extraConfig kTLS;
|
||||
inherit name extraConfig kTLS locations;
|
||||
ssl.cert.copyFromVhost = "unifi";
|
||||
local.enable = true;
|
||||
locations."/" = {
|
||||
proxyPass = mkDefault nginx.virtualHosts.unifi.locations."/".proxyPass;
|
||||
};
|
||||
proxy.url = mkDefault nginx.virtualHosts.unifi.proxy.url;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue