summaryrefslogtreecommitdiff
path: root/hosts/kay/modules/www.nix
diff options
context:
space:
mode:
authorsinanmohd <sinan@sinanmohd.com>2023-09-09 11:45:52 +0530
committersinanmohd <sinan@sinanmohd.com>2023-09-11 13:44:14 +0530
commit146026f7bd704aa80e09fedac08e47754f9ac2f4 (patch)
treed0bf90d69eae592cab13b07befde180a463144be /hosts/kay/modules/www.nix
parente72c86c26271ba88e8b5ea1db9baf1fdd2501945 (diff)
hosts/kay/modules/www: init
Diffstat (limited to 'hosts/kay/modules/www.nix')
-rw-r--r--hosts/kay/modules/www.nix47
1 files changed, 47 insertions, 0 deletions
diff --git a/hosts/kay/modules/www.nix b/hosts/kay/modules/www.nix
new file mode 100644
index 0000000..08548e8
--- /dev/null
+++ b/hosts/kay/modules/www.nix
@@ -0,0 +1,47 @@
+{ config, ... }:
+
+let
+ domain = config.userdata.domain;
+ email = config.userdata.email;
+in
+{
+ imports = [
+ ./dendrite.nix
+ ./cgit.nix
+ ];
+
+ networking.firewall.allowedTCPPorts = [ 80 443 ];
+ security.acme = {
+ acceptTerms = true;
+ defaults.email = email;
+ };
+
+ services.nginx = {
+ enable = true;
+ virtualHosts = {
+ "${domain}" = {
+ forceSSL = true;
+ enableACME = true;
+ globalRedirect = "www.${domain}";
+
+ extraConfig = ''
+ client_max_body_size ${toString config.services.dendrite.settings.media_api.max_file_size_bytes};
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_read_timeout 600;
+ '';
+ locations."/_matrix" = {
+ proxyPass = "http://127.0.0.1:${toString config.services.dendrite.httpPort}";
+ };
+ locations."/.well-known/matrix/server".return = ''
+ 200 '{ "m.server": "${domain}:443" }'
+ '';
+ };
+ "www.${domain}" = {
+ forceSSL = true;
+ enableACME = true;
+ root = "/var/www/${domain}";
+ };
+ };
+ };
+}