2023-11-13 09:51:07 +01:00
|
|
|
{ lib, config, pkgs, ... }:
|
2022-09-06 14:00:29 +02:00
|
|
|
{
|
2023-11-13 11:09:16 +01:00
|
|
|
# set default options for virtualHosts
|
|
|
|
options = with lib; {
|
|
|
|
services.nginx.virtualHosts = mkOption {
|
|
|
|
type = types.attrsOf (types.submodule
|
|
|
|
({ name, ... }: {
|
2024-03-25 19:34:47 +01:00
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
2023-11-13 11:09:16 +01:00
|
|
|
# split up nginx access logs per vhost
|
|
|
|
extraConfig = ''
|
|
|
|
access_log /var/log/nginx/${name}_access.log;
|
|
|
|
error_log /var/log/nginx/${name}_error.log;
|
|
|
|
'';
|
|
|
|
})
|
|
|
|
);
|
|
|
|
};
|
|
|
|
};
|
2023-08-22 15:37:42 +02:00
|
|
|
|
2023-11-13 11:09:16 +01:00
|
|
|
config = {
|
2024-03-28 20:55:47 +01:00
|
|
|
networking.firewall.allowedTCPPorts = [ 443 80 ];
|
2023-11-13 11:09:16 +01:00
|
|
|
services.nginx = {
|
2023-11-13 09:51:07 +01:00
|
|
|
additionalModules = [ pkgs.nginxModules.pam ];
|
|
|
|
enable = true;
|
|
|
|
recommendedProxySettings = true;
|
|
|
|
recommendedGzipSettings = true;
|
|
|
|
recommendedOptimisation = true;
|
|
|
|
recommendedTlsSettings = true;
|
2023-03-01 16:39:41 +01:00
|
|
|
|
2023-11-13 09:51:07 +01:00
|
|
|
# appendHttpConfig = ''
|
|
|
|
# map $remote_addr $remote_addr_anon {
|
|
|
|
# ~(?P<ip>\d+\.\d+\.\d+)\. $ip.0;
|
|
|
|
# ~(?P<ip>[^:]+:[^:]+): $ip::;
|
|
|
|
# # IP addresses to not anonymize
|
|
|
|
# 127.0.0.1 $remote_addr;
|
|
|
|
# ::1 $remote_addr;
|
|
|
|
# default 0.0.0.0;
|
|
|
|
# }
|
|
|
|
# log_format anon_ip '$remote_addr_anon - $remote_user [$time_local] "$request" '
|
|
|
|
# '$status $body_bytes_sent "$http_referer" '
|
|
|
|
# '"$http_user_agent" "$http_x_forwarded_for"';
|
|
|
|
|
|
|
|
# access_log /var/log/nginx/access.log anon_ip;
|
|
|
|
# '';
|
|
|
|
};
|
2023-11-13 11:09:16 +01:00
|
|
|
security.acme = {
|
|
|
|
acceptTerms = true;
|
|
|
|
defaults = {
|
|
|
|
#server = "https://acme-staging-v02.api.letsencrypt.org/directory";
|
|
|
|
email = "root@${config.networking.domain}";
|
|
|
|
};
|
2022-09-06 14:00:29 +02:00
|
|
|
};
|
2023-11-13 11:09:16 +01:00
|
|
|
security.pam.services.nginx.text = ''
|
|
|
|
auth required ${pkgs.nss_pam_ldapd}/lib/security/pam_ldap.so
|
|
|
|
account required ${pkgs.nss_pam_ldapd}/lib/security/pam_ldap.so
|
|
|
|
'';
|
2022-09-06 14:00:29 +02:00
|
|
|
};
|
|
|
|
}
|