Compare commits
3 commits
ae230b5df7
...
60050113bc
Author | SHA1 | Date | |
---|---|---|---|
Bruno BELANYI | 60050113bc | ||
Bruno BELANYI | 6a1a35a384 | ||
Bruno BELANYI | e9d96138d5 |
|
@ -65,9 +65,7 @@ in
|
|||
aria-rpc = {
|
||||
port = cfg.rpcPort;
|
||||
# Proxy websockets for RPC
|
||||
extraConfig = {
|
||||
locations."/".proxyWebsockets = true;
|
||||
};
|
||||
websocketsLocations = [ "/" ];
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -30,9 +30,7 @@ in
|
|||
audiobookshelf = {
|
||||
inherit (cfg) port;
|
||||
# Proxy websockets for RPC
|
||||
extraConfig = {
|
||||
locations."/".proxyWebsockets = true;
|
||||
};
|
||||
websocketsLocations = [ "/" ];
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -27,17 +27,13 @@ in
|
|||
my.services.nginx.virtualHosts = {
|
||||
jellyfin = {
|
||||
port = 8096;
|
||||
websocketsLocations = [ "/socket" ];
|
||||
extraConfig = {
|
||||
locations."/" = {
|
||||
extraConfig = ''
|
||||
proxy_buffering off;
|
||||
'';
|
||||
};
|
||||
# Too bad for the repetition...
|
||||
locations."/socket" = {
|
||||
proxyPass = "http://127.0.0.1:8096/";
|
||||
proxyWebsockets = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -40,18 +40,10 @@ in
|
|||
my.services.nginx.virtualHosts = {
|
||||
collabora = {
|
||||
inherit (cfg) port;
|
||||
|
||||
extraConfig = {
|
||||
# Too bad for the repetition...
|
||||
locations."~ ^/cool/(.*)/ws$" = {
|
||||
proxyPass = "http://127.0.0.1:${builtins.toString cfg.port}";
|
||||
proxyWebsockets = true;
|
||||
};
|
||||
locations."^~ /cool/adminws" = {
|
||||
proxyPass = "http://127.0.0.1:${builtins.toString cfg.port}";
|
||||
proxyWebsockets = true;
|
||||
};
|
||||
};
|
||||
websocketsLocations = [
|
||||
"~ ^/cool/(.*)/ws$"
|
||||
"^~ /cool/adminws"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -17,6 +17,16 @@ let
|
|||
'';
|
||||
};
|
||||
|
||||
websocketsLocations = mkOption {
|
||||
type = with types; listOf str;
|
||||
default = [ ];
|
||||
example = [ "/socket" ];
|
||||
description = ''
|
||||
Which locations on this virtual host should be configured for
|
||||
websockets.
|
||||
'';
|
||||
};
|
||||
|
||||
port = mkOption {
|
||||
type = with types; nullOr port;
|
||||
default = null;
|
||||
|
@ -60,10 +70,13 @@ let
|
|||
extraConfig = mkOption {
|
||||
type = types.attrs; # FIXME: forward type of virtualHosts
|
||||
example = {
|
||||
locations."/socket" = {
|
||||
proxyPass = "http://127.0.0.1:8096/";
|
||||
proxyWebsockets = true;
|
||||
};
|
||||
extraConfig = ''
|
||||
add_header X-Clacks-Overhead "GNU Terry Pratchett";
|
||||
'';
|
||||
|
||||
locations."/".extraConfig = ''
|
||||
client_max_body_size 1G;
|
||||
'';
|
||||
};
|
||||
default = { };
|
||||
description = ''
|
||||
|
@ -108,12 +121,7 @@ in
|
|||
};
|
||||
jellyfin = {
|
||||
port = 8096;
|
||||
extraConfig = {
|
||||
locations."/socket" = {
|
||||
proxyPass = "http://127.0.0.1:8096/";
|
||||
proxyWebsockets = true;
|
||||
};
|
||||
};
|
||||
websocketsLocations = [ "/socket" ];
|
||||
};
|
||||
};
|
||||
description = ''
|
||||
|
@ -195,6 +203,19 @@ in
|
|||
} configured.
|
||||
'';
|
||||
}))
|
||||
++ (lib.flip lib.mapAttrsToList cfg.virtualHosts (_: { subdomain, ... } @ args:
|
||||
let
|
||||
proxyPass = [ "port" "socket" ];
|
||||
proxyPassUsed = lib.any (v: args.${v} != null) proxyPass;
|
||||
in
|
||||
{
|
||||
assertion = args.websocketsLocations != [ ] -> proxyPassUsed;
|
||||
message = ''
|
||||
Subdomain '${subdomain}' can only use 'websocketsLocations' with one of ${
|
||||
lib.concatStringsSep ", " (builtins.map (v: "'${v}'") proxyPass)
|
||||
}.
|
||||
'';
|
||||
}))
|
||||
++ (
|
||||
let
|
||||
ports = lib.my.mapFilter
|
||||
|
@ -241,6 +262,14 @@ in
|
|||
virtualHosts =
|
||||
let
|
||||
domain = config.networking.domain;
|
||||
mkProxyPass = { websocketsLocations, ... }: proxyPass:
|
||||
let
|
||||
websockets = lib.genAttrs websocketsLocations (_: {
|
||||
inherit proxyPass;
|
||||
proxyWebsockets = true;
|
||||
});
|
||||
in
|
||||
{ "/" = { inherit proxyPass; }; } // websockets;
|
||||
mkVHost = ({ subdomain, ... } @ args: lib.nameValuePair
|
||||
"${subdomain}.${domain}"
|
||||
(lib.my.recursiveMerge [
|
||||
|
@ -251,8 +280,7 @@ in
|
|||
}
|
||||
# Proxy to port
|
||||
(lib.optionalAttrs (args.port != null) {
|
||||
locations."/".proxyPass =
|
||||
"http://127.0.0.1:${toString args.port}";
|
||||
locations = mkProxyPass args "http://127.0.0.1:${toString args.port}";
|
||||
})
|
||||
# Serve filesystem content
|
||||
(lib.optionalAttrs (args.root != null) {
|
||||
|
@ -260,8 +288,7 @@ in
|
|||
})
|
||||
# Serve to UNIX socket
|
||||
(lib.optionalAttrs (args.socket != null) {
|
||||
locations."/".proxyPass =
|
||||
"http://unix:${args.socket}";
|
||||
locations = mkProxyPass args "http://unix:${args.socket}";
|
||||
})
|
||||
# Redirect to a different domain
|
||||
(lib.optionalAttrs (args.redirect != null) {
|
||||
|
|
|
@ -152,11 +152,7 @@ in
|
|||
sso = {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
# Enable websockets on root
|
||||
extraConfig = {
|
||||
locations."/".proxyWebsockets = true;
|
||||
};
|
||||
websocketsLocations = [ "/" ];
|
||||
};
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue