141 lines
4.3 KiB
Nix
Raw Normal View History

2022-02-14 03:33:03 +03:00
{ config, lib, pkgs, ... }: {
security.acme = {
acceptTerms = true;
2022-03-10 19:12:07 +03:00
defaults.email = "ataraxiadev@ataraxiadev.com";
2022-02-14 03:33:03 +03:00
certs = {
"ataraxiadev.com" = {
webroot = "/var/lib/acme/acme-challenge";
extraDomainNames = [
"matrix.ataraxiadev.com"
"cinny.ataraxiadev.com"
"dimension.ataraxiadev.com"
"element.ataraxiadev.com"
"goneb.ataraxiadev.com"
"jitsi.ataraxiadev.com"
"stats.ataraxiadev.com"
2022-02-19 00:15:28 +03:00
"startpage.ataraxiadev.com"
2022-02-21 02:25:13 +03:00
"vw.ataraxiadev.com"
2022-03-10 19:12:07 +03:00
"code.ataraxiadev.com"
2022-03-22 06:02:13 +03:00
"file.ataraxiadev.com"
2022-03-22 06:01:10 +03:00
"webmail.ataraxiadev.com"
2022-02-14 03:33:03 +03:00
];
};
};
};
services.nginx = {
enable = true;
group = "acme";
recommendedOptimisation = true;
recommendedGzipSettings = true;
recommendedTlsSettings = true;
2022-03-22 06:02:13 +03:00
clientMaxBodySize = "250m";
2022-02-14 03:33:03 +03:00
virtualHosts = let
default = {
useACMEHost = "ataraxiadev.com";
2022-03-22 06:01:10 +03:00
enableACME = false;
2022-02-14 03:33:03 +03:00
forceSSL = true;
};
2022-02-21 02:25:13 +03:00
proxySettings = {
2022-02-14 03:33:03 +03:00
extraConfig = ''
proxy_set_header Host $host;
2022-02-21 02:25:13 +03:00
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
'';
};
hardened = {
extraConfig = ''
add_header X-XSS-Protection "1; mode=block";
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Robots-Tag "none";
add_header Referrer-Policy "strict-origin-when-cross-origin";
add_header X-Content-Type-Options "nosniff";
2022-02-14 03:33:03 +03:00
'';
};
in {
"ataraxiadev.com" = {
locations."/.well-known/matrix" = {
proxyPass = "https://matrix.ataraxiadev.com/.well-known/matrix";
extraConfig = ''
proxy_set_header X-Forwarded-For $remote_addr;
'';
2022-03-10 19:12:07 +03:00
};
2022-02-14 03:33:03 +03:00
} // default;
"matrix:443" = {
serverAliases = [
"matrix.ataraxiadev.com"
"cinny.ataraxiadev.com"
"dimension.ataraxiadev.com"
"element.ataraxiadev.com"
"goneb.ataraxiadev.com"
"jitsi.ataraxiadev.com"
"stats.ataraxiadev.com"
];
listen = [{
addr = "0.0.0.0";
port = 443;
ssl = true;
}];
locations."/" = {
2022-03-10 19:12:07 +03:00
proxyPass = "http://matrix.pve:81";
} // proxySettings;
2022-02-14 03:33:03 +03:00
} // default;
"matrix:8448" = {
serverAliases = [ "matrix.ataraxiadev.com" ];
listen = [{
addr = "0.0.0.0";
port = 8448;
ssl = true;
}];
locations."/" = {
2022-03-10 19:12:07 +03:00
proxyPass = "http://matrix.pve:8449";
} // proxySettings;
2022-02-14 03:33:03 +03:00
} // default;
2022-02-19 00:15:28 +03:00
"startpage.ataraxiadev.com" = {
locations."/" = {
root = "/srv/http/startpage.ataraxiadev.com/";
2022-02-21 02:25:13 +03:00
extraConfig = ''
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag "none";
add_header Referrer-Policy "strict-origin-when-cross-origin";
add_header X-Content-Type-Options "nosniff";
'';
2022-02-19 00:15:28 +03:00
};
} // default;
2022-02-21 02:25:13 +03:00
"vw.ataraxiadev.com" = {
locations."/" = {
proxyPass = "http://localhost:8812";
} // proxySettings // hardened;
locations."/notifications/hub" = {
proxyPass = "http://localhost:3012";
proxyWebsockets = true;
} // proxySettings // hardened;
locations."/notifications/hub/negotiate" = {
proxyPass = "http://localhost:8812";
} // proxySettings // hardened;
} // default;
2022-03-10 19:12:07 +03:00
"code.ataraxiadev.com" = {
locations."/" = {
proxyPass = "http://localhost:6000";
} // proxySettings // hardened;
} // default;
2022-03-22 06:02:13 +03:00
"file.ataraxiadev.com" = {
locations."/" = {
proxyPass = "http://localhost:8088/";
} // proxySettings // hardened;
} // default;
2022-03-22 06:01:10 +03:00
"webmail.ataraxiadev.com" = {
locations."/" = {
extraConfig = ''
client_max_body_size 30M;
'';
} // hardened;
} // default;
2022-02-14 03:33:03 +03:00
};
};
networking.firewall.allowedTCPPorts = [ 80 443 8448 ];
}