2023-11-10 03:10:06 +00:00
|
|
|
{ config, lib, ... }:
|
2021-11-15 10:02:05 +00:00
|
|
|
let
|
2023-11-16 00:00:11 +00:00
|
|
|
domain = config.selfprivacy.domain;
|
2021-11-15 10:02:05 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
services.nginx = {
|
|
|
|
enable = true;
|
|
|
|
recommendedGzipSettings = true;
|
|
|
|
recommendedOptimisation = true;
|
|
|
|
recommendedProxySettings = true;
|
|
|
|
recommendedTlsSettings = true;
|
2021-12-17 17:17:23 +00:00
|
|
|
sslProtocols = lib.mkForce "TLSv1.2 TLSv1.3";
|
|
|
|
sslCiphers = lib.mkForce "ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:!SHA1:!SHA256:!SHA384:!DSS:!aNULL";
|
2021-11-15 10:02:05 +00:00
|
|
|
clientMaxBodySize = "1024m";
|
2021-12-17 17:17:23 +00:00
|
|
|
commonHttpConfig = ''
|
|
|
|
map $scheme $hsts_header {
|
|
|
|
https "max-age=31536000; includeSubdomains; preload";
|
|
|
|
}
|
2023-12-12 16:35:44 +00:00
|
|
|
proxy_headers_hash_bucket_size 128;
|
|
|
|
proxy_headers_hash_max_size 512;
|
2021-12-17 17:17:23 +00:00
|
|
|
'';
|
2021-11-15 10:02:05 +00:00
|
|
|
virtualHosts = {
|
|
|
|
"${domain}" = {
|
2024-09-06 21:18:46 +00:00
|
|
|
useACMEHost = "root-${domain}";
|
2021-11-15 10:02:05 +00:00
|
|
|
forceSSL = true;
|
2021-12-17 17:17:23 +00:00
|
|
|
extraConfig = ''
|
|
|
|
add_header Strict-Transport-Security $hsts_header;
|
2021-12-21 06:18:38 +00:00
|
|
|
#add_header Content-Security-Policy "script-src 'self'; object-src 'none'; base-uri 'none';" always;
|
2021-12-17 17:17:23 +00:00
|
|
|
add_header 'Referrer-Policy' 'origin-when-cross-origin';
|
|
|
|
add_header X-Frame-Options DENY;
|
|
|
|
add_header X-Content-Type-Options nosniff;
|
|
|
|
add_header X-XSS-Protection "1; mode=block";
|
|
|
|
proxy_cookie_path / "/; secure; HttpOnly; SameSite=strict";
|
|
|
|
'';
|
2023-12-19 12:19:22 +00:00
|
|
|
locations = {
|
|
|
|
"/" = {
|
|
|
|
root = "/var/www/root";
|
|
|
|
};
|
|
|
|
};
|
2021-11-15 10:02:05 +00:00
|
|
|
};
|
|
|
|
"api.${domain}" = {
|
2023-12-22 15:57:48 +00:00
|
|
|
useACMEHost = domain;
|
2021-11-15 10:02:05 +00:00
|
|
|
forceSSL = true;
|
2021-12-17 17:17:23 +00:00
|
|
|
extraConfig = ''
|
|
|
|
add_header Strict-Transport-Security $hsts_header;
|
2021-12-21 06:18:38 +00:00
|
|
|
#add_header Content-Security-Policy "script-src 'self'; object-src 'none'; base-uri 'none';" always;
|
2021-12-17 17:17:23 +00:00
|
|
|
add_header 'Referrer-Policy' 'origin-when-cross-origin';
|
|
|
|
add_header X-Frame-Options DENY;
|
|
|
|
add_header X-Content-Type-Options nosniff;
|
|
|
|
add_header X-XSS-Protection "1; mode=block";
|
|
|
|
proxy_cookie_path / "/; secure; HttpOnly; SameSite=strict";
|
|
|
|
'';
|
2021-11-15 10:02:05 +00:00
|
|
|
locations = {
|
|
|
|
"/" = {
|
|
|
|
proxyPass = "http://127.0.0.1:5050";
|
2022-08-26 10:21:05 +00:00
|
|
|
proxyWebsockets = true;
|
2021-11-15 10:02:05 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-12-19 12:19:22 +00:00
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"d /var/www/root 0750 nginx nginx - -"
|
|
|
|
];
|
2021-11-15 10:02:05 +00:00
|
|
|
}
|