nginx proxy module
This commit is contained in:
100
modules/network/nginx.nix
Normal file
100
modules/network/nginx.nix
Normal file
@@ -0,0 +1,100 @@
|
||||
{ lib, config, ... }:
|
||||
let
|
||||
setup = import ../servers/setup.nix { inherit lib config; };
|
||||
|
||||
standardProxyServices = {
|
||||
"firefox-syncserver" = {
|
||||
type = "proxyReverse";
|
||||
};
|
||||
"readeck" = {
|
||||
type = "proxyReverse";
|
||||
};
|
||||
"microbin" = {
|
||||
type = "proxyReverse";
|
||||
};
|
||||
"ryot" = {
|
||||
type = "proxyReverse";
|
||||
};
|
||||
"bazarr" = {
|
||||
type = "proxyReverse";
|
||||
};
|
||||
"shiori" = {
|
||||
type = "proxyReverse";
|
||||
};
|
||||
"metube" = {
|
||||
type = "proxyReverse";
|
||||
};
|
||||
"maloja" = {
|
||||
type = "proxyReverse";
|
||||
};
|
||||
"vaultwarden" = {
|
||||
type = "proxyReverse";
|
||||
};
|
||||
"mealie" = {
|
||||
type = "proxyReverse";
|
||||
};
|
||||
"kavita" = {
|
||||
type = "proxyReverse";
|
||||
};
|
||||
"multi-scrobbler" = {
|
||||
type = "proxyReverse";
|
||||
};
|
||||
"nix-serve" = {
|
||||
type = "proxyReverse";
|
||||
};
|
||||
"audiobookshelf" = {
|
||||
type = "proxyReverseFix";
|
||||
};
|
||||
"lidarr" = {
|
||||
type = "proxyReverseFix";
|
||||
};
|
||||
"gitea" = {
|
||||
type = "proxyReverseFix";
|
||||
};
|
||||
"prowlarr" = {
|
||||
type = "proxyReverseFix";
|
||||
};
|
||||
"ombi" = {
|
||||
type = "proxyReverseFix";
|
||||
};
|
||||
"radarr" = {
|
||||
type = "proxyReverseFix";
|
||||
};
|
||||
"sonarr" = {
|
||||
type = "proxyReverseFix";
|
||||
};
|
||||
"stash" = {
|
||||
type = "proxyReverseFix";
|
||||
};
|
||||
"atticd" = {
|
||||
type = "proxyReverseFix";
|
||||
};
|
||||
"homepage" = {
|
||||
type = "proxyReversePrivate";
|
||||
};
|
||||
};
|
||||
|
||||
generateProxyConfig =
|
||||
serviceName: serviceConfig:
|
||||
let
|
||||
cfg = config.my.servers.${serviceName};
|
||||
proxyFunc =
|
||||
if serviceConfig.type == "proxyReverse" then
|
||||
setup.proxyReverse
|
||||
else if serviceConfig.type == "proxyReverseFix" then
|
||||
setup.proxyReverseFix
|
||||
else if serviceConfig.type == "proxyReversePrivate" then
|
||||
setup.proxyReversePrivate
|
||||
else
|
||||
throw "Unknown proxy type: ${serviceConfig.type}";
|
||||
in
|
||||
lib.nameValuePair cfg.host (lib.mkIf cfg.enableProxy (proxyFunc cfg));
|
||||
|
||||
standardProxyConfigs = lib.mapAttrs' generateProxyConfig standardProxyServices;
|
||||
|
||||
in
|
||||
{
|
||||
config = lib.mkIf config.my.enableProxy {
|
||||
services.nginx.virtualHosts = standardProxyConfigs;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user