nixos-config/hosts/falkenstein-1/modules/nginx/default.nix

47 lines
1.2 KiB
Nix
Raw Normal View History

2023-09-19 13:47:08 +02:00
{ config, ... }:
2023-10-17 10:39:14 +02:00
# matrix homeserver discovery
let
matrix_domain = "matrix.${config.networking.domain}";
serverConfig = {
"m.server" = "${matrix_domain}:443";
};
clientConfig = {
"m.homeserver" = {
base_url = "https://${matrix_domain}";
# server_name = config.networking.domain;
};
"org.matrix.msc3575.proxy" = {
url = "https://${matrix_domain}";
};
};
mkWellKnown = data: ''
add_header Content-Type application/json;
add_header Access-Control-Allow-Origin *;
return 200 '${builtins.toJSON data}';
'';
in
2023-04-12 17:21:24 +02:00
{
networking.firewall.allowedTCPPorts = [ 80 443 ];
2023-05-05 23:43:40 +02:00
services.nginx = {
enable = true;
recommendedTlsSettings = true;
recommendedProxySettings = true;
recommendedGzipSettings = true;
recommendedOptimisation = true;
2023-05-30 17:33:15 +02:00
2023-09-19 13:47:08 +02:00
virtualHosts."${config.networking.domain}" = {
2023-05-24 16:37:45 +02:00
enableACME = true;
forceSSL = true;
2023-09-19 13:47:08 +02:00
root = "/srv/web/${config.networking.domain}";
2023-10-17 10:39:14 +02:00
locations."/.well-known/matrix/client".extraConfig = mkWellKnown clientConfig;
locations."/.well-known/matrix/server".extraConfig = mkWellKnown serverConfig;
2023-05-24 16:37:45 +02:00
};
2023-05-05 23:43:40 +02:00
};
2023-04-12 17:21:24 +02:00
security.acme = {
acceptTerms = true;
defaults = {
2023-09-19 13:47:08 +02:00
email = "rouven@${config.networking.domain}";
2023-04-12 17:21:24 +02:00
};
};
}