2019-02-26 13:44:40 +01:00
|
|
|
##############################################################################################
|
|
|
|
# Includes: #
|
|
|
|
# - Nginx + SSL config #
|
|
|
|
# - Gitea #
|
2019-03-24 22:55:17 +01:00
|
|
|
# - Hydra #
|
2019-02-26 13:44:40 +01:00
|
|
|
# - Nextcloud #
|
|
|
|
# - Mail ssl root #
|
|
|
|
##############################################################################################
|
|
|
|
|
2019-09-08 15:27:22 +02:00
|
|
|
{ options, config, lib, pkgs, ... }:
|
2019-02-26 13:44:40 +01:00
|
|
|
|
2019-03-20 02:57:59 +01:00
|
|
|
with lib;
|
2019-06-22 23:58:08 +02:00
|
|
|
with builtins;
|
2019-03-20 02:57:59 +01:00
|
|
|
|
|
|
|
mkIf (elem "nginx" config.machine.services) {
|
2019-06-22 23:58:08 +02:00
|
|
|
services.nginx = let
|
|
|
|
vHostConfigs = listToAttrs (map
|
|
|
|
(name: {
|
|
|
|
name = (replaceStrings [ ".nix" ] [ "" ] name);
|
2019-09-08 15:27:22 +02:00
|
|
|
value = (import (./. + (toPath "/nginx_vHosts/${name}")) { inherit options config lib pkgs; });})
|
2019-06-22 23:58:08 +02:00
|
|
|
(attrNames (readDir ./nginx_vHosts)));
|
|
|
|
|
|
|
|
mkVHost = vHost: {
|
|
|
|
name = vHost.domain;
|
|
|
|
value = {
|
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
|
|
|
} // vHostConfigs."${vHost.service}"; };
|
|
|
|
|
|
|
|
vHosts = listToAttrs (map mkVHost config.machine.vHosts);
|
|
|
|
|
|
|
|
in {
|
2019-02-26 13:44:40 +01:00
|
|
|
enable = true;
|
|
|
|
recommendedGzipSettings = true;
|
|
|
|
recommendedOptimisation = true;
|
|
|
|
recommendedProxySettings = true;
|
2019-03-20 04:37:00 +01:00
|
|
|
recommendedTlsSettings = true;
|
|
|
|
sslCiphers = "EECDH+aRSA+AESGCM:EDH+aRSA:EECDH+aRSA:+AES256:+AES128:+SHA1:!CAMELLIA:!SEED:!3DES:!DES:!RC4:!eNULL";
|
|
|
|
sslProtocols = "TLSv1.3 TLSv1.2";
|
|
|
|
commonHttpConfig = ''
|
2019-04-03 00:06:08 +02:00
|
|
|
map $scheme $hsts_header {
|
|
|
|
https "max-age=31536000; includeSubdomains; preload";
|
|
|
|
}
|
|
|
|
add_header Strict-Transport-Security $hsts_header;
|
|
|
|
add_header 'Referrer-Policy' 'origin-when-cross-origin';
|
2019-10-06 18:30:47 +02:00
|
|
|
# add_header X-Frame-Options DENY;
|
2019-04-03 00:06:08 +02:00
|
|
|
add_header X-Content-Type-Options nosniff;
|
|
|
|
add_header X-XSS-Protection "1; mode=block";
|
2019-03-20 04:37:00 +01:00
|
|
|
'';
|
2019-06-22 23:58:08 +02:00
|
|
|
virtualHosts = vHosts;
|
2019-02-26 13:44:40 +01:00
|
|
|
};
|
|
|
|
}
|