mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 12:29:19 -08:00
refactor(nginx): websocket proxy settings
This commit is contained in:
parent
a0bd07f898
commit
ba7f32ddcb
4 changed files with 52 additions and 26 deletions
|
|
@ -4,7 +4,7 @@
|
|||
...
|
||||
}: let
|
||||
inherit (lib.options) mkOption;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.modules) mkIf mkOptionDefault;
|
||||
cfg = config.services.plex;
|
||||
access = config.services.nginx.access.plex;
|
||||
in {
|
||||
|
|
@ -23,7 +23,7 @@ in {
|
|||
};
|
||||
config.services.nginx = {
|
||||
access.plex = mkIf cfg.enable {
|
||||
url = "http://localhost:32400";
|
||||
url = mkOptionDefault "http://localhost:32400";
|
||||
};
|
||||
virtualHosts = let
|
||||
extraConfig = ''
|
||||
|
|
@ -46,18 +46,18 @@ in {
|
|||
proxy_redirect off;
|
||||
proxy_buffering off;
|
||||
'';
|
||||
location = {
|
||||
proxy.websocket.enable = true;
|
||||
proxyPass = access.url;
|
||||
};
|
||||
in {
|
||||
${access.domain} = {
|
||||
locations."/" = {
|
||||
proxyPass = access.url;
|
||||
};
|
||||
locations."/" = location;
|
||||
inherit extraConfig;
|
||||
};
|
||||
${access.localDomain} = {
|
||||
local.enable = true;
|
||||
locations."/" = {
|
||||
proxyPass = access.url;
|
||||
};
|
||||
locations."/" = location;
|
||||
inherit extraConfig;
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -59,12 +59,10 @@ in {
|
|||
'';
|
||||
};
|
||||
locations."/prox/api2/" = {
|
||||
proxy.websocket.enable = true;
|
||||
proxyPass = "${proxyPass}api2/";
|
||||
extraConfig = ''
|
||||
internal;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
|
@ -73,6 +71,7 @@ in {
|
|||
forceSSL = mkDefault true;
|
||||
inherit sslCertificate sslCertificateKey;
|
||||
locations."/" = {
|
||||
proxy.websocket.enable = true;
|
||||
inherit proxyPass;
|
||||
};
|
||||
};
|
||||
|
|
@ -80,6 +79,7 @@ in {
|
|||
local.enable = mkDefault true;
|
||||
inherit sslCertificate sslCertificateKey;
|
||||
locations."/" = {
|
||||
proxy.websocket.enable = true;
|
||||
inherit proxyPass;
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,12 +8,10 @@ let
|
|||
inherit (lib.modules) mkIf mkDefault mkOptionDefault;
|
||||
cfg = config.services.zigbee2mqtt;
|
||||
access = config.services.nginx.access.zigbee2mqtt;
|
||||
proxyPass = mkDefault "http://${access.host}:${toString access.port}";
|
||||
extraConfig = ''
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_http_version 1.1;
|
||||
'';
|
||||
location = {
|
||||
proxy.websocket.enable = true;
|
||||
proxyPass = mkDefault "http://${access.host}:${toString access.port}";
|
||||
};
|
||||
in {
|
||||
options.services.nginx.access.zigbee2mqtt = with lib.types; {
|
||||
host = mkOption {
|
||||
|
|
@ -41,21 +39,15 @@ in {
|
|||
virtualHosts = {
|
||||
${access.domain} = {
|
||||
vouch.enable = true;
|
||||
locations."/" = {
|
||||
inherit proxyPass extraConfig;
|
||||
};
|
||||
locations."/" = location;
|
||||
};
|
||||
${access.localDomain} = {
|
||||
local.enable = true;
|
||||
locations."/" = {
|
||||
inherit proxyPass extraConfig;
|
||||
};
|
||||
locations."/" = location;
|
||||
};
|
||||
"z2m.tail.${config.networking.domain}" = mkIf config.services.tailscale.enable {
|
||||
local.enable = true;
|
||||
locations."/" = {
|
||||
inherit proxyPass extraConfig;
|
||||
};
|
||||
locations."/" = location;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue