1
0

Compare commits

...

2 Commits

Author SHA1 Message Date
64a1924f4a Enable SSL for nginx port forward 2021-01-03 16:03:42 +01:00
d1fd780e79 Enable znc server 2021-01-03 15:19:40 +01:00
3 changed files with 45 additions and 2 deletions

View File

@ -8,6 +8,7 @@
./bubblesort.nix
./ip.nix
./meow.nix
./znc.nix
];
boot.loader.grub.enable = true;

29
hosts/web-2/znc.nix Normal file
View File

@ -0,0 +1,29 @@
{ ... }:
{
services.znc = {
enable = true;
mutable = true;
dataDir = "/var/lib/znc";
configFile = "/var/lib/znc/configs/znc.conf";
};
services.nginx.virtualHosts = {
"znc.clerie.de" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://127.0.0.1:1313";
};
};
};
clerie.nginx-port-forward = {
enable = true;
tcpPorts."6697" = {
host = "127.0.0.1";
port = 1311;
certName = "znc.clerie.de";
};
};
}

View File

@ -4,11 +4,20 @@ with lib;
let
cfg = config.clerie.nginx-port-forward;
certs = config.security.acme.certs;
sslDhparam = config.services.nginx.sslDhparam;
mkServerBlock = isUDP: port: forward: ''
server {
listen ${port}${optionalString isUDP " udp"};
listen [::]:${port}${optionalString isUDP " udp"};
listen ${port}${optionalString isUDP " udp"}${optionalString (forward.certName != null) " ssl"};
listen [::]:${port}${optionalString isUDP " udp"}${optionalString (forward.certName != null) " ssl"};
${ optionalString (forward.certName != null) ''
ssl_certificate ${certs.${forward.certName}.directory}/fullchain.pem;
ssl_certificate_key ${certs.${forward.certName}.directory}/key.pem;
${ optionalString (sslDhparam != null) "ssl_dhparam ${sslDhparam};" }
'' }
proxy_pass ${forward.host}:${toString forward.port};
}
'';
@ -28,6 +37,10 @@ let
port = mkOption {
type = types.int;
};
certName = mkOption {
type = with types; nullOr str;
default = null;
};
};
};