Enable SSL for nginx port forward
This commit is contained in:
parent
d1fd780e79
commit
64a1924f4a
@ -4,11 +4,20 @@ with lib;
|
|||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.clerie.nginx-port-forward;
|
cfg = config.clerie.nginx-port-forward;
|
||||||
|
certs = config.security.acme.certs;
|
||||||
|
sslDhparam = config.services.nginx.sslDhparam;
|
||||||
|
|
||||||
mkServerBlock = isUDP: port: forward: ''
|
mkServerBlock = isUDP: port: forward: ''
|
||||||
server {
|
server {
|
||||||
listen ${port}${optionalString isUDP " udp"};
|
listen ${port}${optionalString isUDP " udp"}${optionalString (forward.certName != null) " ssl"};
|
||||||
listen [::]:${port}${optionalString isUDP " udp"};
|
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};
|
proxy_pass ${forward.host}:${toString forward.port};
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
@ -28,6 +37,10 @@ let
|
|||||||
port = mkOption {
|
port = mkOption {
|
||||||
type = types.int;
|
type = types.int;
|
||||||
};
|
};
|
||||||
|
certName = mkOption {
|
||||||
|
type = with types; nullOr str;
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user