nixfiles/config/services/nginx.nix

50 lines
1.6 KiB
Nix
Raw Permalink Normal View History

2024-11-04 18:51:13 +01:00
{ config, lib, pkgs, ... }: let
inherit (lib) mkDefault;
in {
kyouma.deployment.tags = [ "web" ];
2024-01-10 13:32:18 +01:00
security.dhparams.enable = true;
security.dhparams.params.nginx = {};
security.acme = {
acceptTerms = true;
defaults = {
keyType = "ec256";
email = "noc@kyouma.net";
};
};
2024-11-04 21:19:57 +01:00
networking.firewall.allowedTCPPorts = [ 80 443 ];
2024-11-04 18:51:13 +01:00
networking.firewall.allowedUDPPorts = [ 443 ];
2024-01-10 13:32:18 +01:00
services.nginx = {
enable = true;
2024-11-04 18:51:13 +01:00
package = mkDefault pkgs.nginxQuic;
2024-01-10 13:32:18 +01:00
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
sslCiphers = "AES256+EECDH:AES256+EDH:!aNULL";
2024-01-11 12:43:58 +01:00
sslProtocols = mkDefault "TLSv1.3";
2024-01-10 13:32:18 +01:00
sslDhparam = config.security.dhparams.params.nginx.path;
2024-01-11 12:43:58 +01:00
clientMaxBodySize = mkDefault "128M";
2024-01-10 13:32:18 +01:00
commonHttpConfig = ''
map $scheme $hsts_header {
2024-01-11 12:43:58 +01:00
https "max-age=31536000; includeSubdomains; preload";
2024-01-10 13:32:18 +01:00
}
2024-01-11 12:43:58 +01:00
add_header Strict-Transport-Security $hsts_header;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header Referrer-Policy "same-origin" always;
2024-11-04 18:51:13 +01:00
add_header Alt-Svc 'h3=":443"; ma=7776000; persist=1, h2=":443"; ma=7776000; persist=1';
2024-01-11 12:43:58 +01:00
#add_header Content-Security-Policy "script-src 'self'; object-src 'none'; base-uri 'none';" always;
2024-01-10 13:32:18 +01:00
'';
2024-09-27 00:06:27 +02:00
eventsConfig = ''
multi_accept on;
'';
appendConfig = ''
worker_processes auto;
'';
2024-01-10 13:32:18 +01:00
};
}