]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - systems/eldiron/websites/mastodon/default.nix
Squash changes containing private information
[perso/Immae/Config/Nix.git] / systems / eldiron / websites / mastodon / default.nix
similarity index 60%
rename from modules/private/websites/tools/mastodon/default.nix
rename to systems/eldiron/websites/mastodon/default.nix
index 173a4b841b14e649dd802ad188322950e25dcb7f..603fc9eaf6aee844089a02edc3dc720d3f6ca9ff 100644 (file)
@@ -3,13 +3,38 @@ let
   env = config.myEnv.tools.mastodon;
   root = "${mcfg.workdir}/public/";
   cfg = config.myServices.websites.tools.mastodon;
-  mcfg = config.services.mastodon;
+  mcfg = config.immaeServices.mastodon;
 in {
   options.myServices.websites.tools.mastodon = {
     enable = lib.mkEnableOption "enable mastodon's website";
   };
 
   config = lib.mkIf cfg.enable {
+    myServices.dns.zones."immae.eu".subdomains.mastodon =
+      with config.myServices.dns.helpers; ips servers.eldiron.ips.main;
+
+    myServices.chatonsProperties.services.mastodon = {
+      file.datetime = "2022-08-21T19:50:00";
+      service = {
+        name = "Mastodon";
+        description = "Your self-hosted, globally interconnected microblogging community";
+        website = "https://mastodon.immae.eu/";
+        logo = "https://mastodon.immae.eu/apple-touch-icon.png";
+        status.level = "OK";
+        status.description = "OK";
+        registration."" = ["MEMBER" "CLIENT"];
+        registration.load = "OPEN";
+        install.type = "PACKAGE";
+      };
+      software = {
+        name = "Mastodon";
+        website = "https://joinmastodon.org/";
+        license.url = "https://github.com/tootsuite/mastodon/blob/master/LICENSE";
+        license.name = "GNU General Public License v3.0";
+        version = mcfg.package.version;
+        source.url = "https://github.com/tootsuite/mastodon";
+      };
+    };
     secrets.keys."webapps/tools-mastodon" = {
       user = "mastodon";
       group = "mastodon";
@@ -56,7 +81,7 @@ in {
         LDAP_SEARCH_FILTER="${env.ldap.filter}"
       '';
     };
-    services.mastodon = {
+    immaeServices.mastodon = {
       enable = true;
       configFile = config.secrets.fullPaths."webapps/tools-mastodon";
       socketsPrefix = "live_immae";
@@ -79,9 +104,9 @@ in {
     services.websites.env.tools.modules = [
       "headers" "proxy" "proxy_wstunnel" "proxy_http"
     ];
+    security.acme.certs.eldiron.extraDomainNames = [ "mastodon.immae.eu" ];
     services.websites.env.tools.vhostConfs.mastodon = {
       certName    = "eldiron";
-      addToCerts  = true;
       hosts       = ["mastodon.immae.eu" ];
       root        = root;
       extraConfig = [ ''
@@ -98,19 +123,19 @@ in {
 
         RewriteEngine On
 
-        ProxyPass /500.html !
-        ProxyPass /sw.js !
-        ProxyPass /embed.js !
-        ProxyPass /robots.txt !
-        ProxyPass /manifest.json !
-        ProxyPass /browserconfig.xml !
-        ProxyPass /mask-icon.svg !
-        ProxyPassMatch ^(/.*\.(png|ico|gif)$) !
-        ProxyPassMatch ^/(assets|avatars|emoji|headers|packs|sounds|system|.well-known/acme-challenge) !
-
         RewriteRule ^/api/v1/streaming/(.+)$ unix://${mcfg.sockets.node}|http://mastodon.immae.eu/api/v1/streaming/$1 [P,NE,QSA,L]
+        RewriteRule ^/api/v1/streaming/public$ unix://${mcfg.sockets.node}|http://mastodon.immae.eu/api/v1/streaming/public [P,NE,QSA,L]
         RewriteRule ^/api/v1/streaming/$ unix://${mcfg.sockets.node}|ws://mastodon.immae.eu/ [P,NE,QSA,L]
-        ProxyPass / unix://${mcfg.sockets.rails}|http://mastodon.immae.eu/
+        RewriteCond %{REQUEST_URI} !/500.html
+        RewriteCond %{REQUEST_URI} !/sw.js
+        RewriteCond %{REQUEST_URI} !/embed.js
+        RewriteCond %{REQUEST_URI} !/robots.txt
+        RewriteCond %{REQUEST_URI} !/manifest.json
+        RewriteCond %{REQUEST_URI} !/browserconfig.xml
+        RewriteCond %{REQUEST_URI} !/mask-icon.svg
+        RewriteCond %{REQUEST_URI} !^(/.*\.(png|ico|gif)$)
+        RewriteCond %{REQUEST_URI} !^/(assets|avatars|emoji|headers|packs|sounds|system|.well-known/acme-challenge)
+        RewriteRule ^/(.*)$ unix:///run/mastodon/live_immae_puma.sock|http://mastodon.immae.eu/$1 [P,NE,QSA,L]
         ProxyPassReverse / unix://${mcfg.sockets.rails}|http://mastodon.immae.eu/
 
         Alias /system ${mcfg.dataDir}
@@ -132,5 +157,18 @@ in {
         ErrorDocument 504 /500.html
       '' ];
     };
+    myServices.monitoring.fromMasterActivatedPlugins = [ "http" ];
+    myServices.monitoring.fromMasterObjects.service = [
+      {
+        service_description = "mastodon website is running on mastodon.immae.eu";
+        host_name = config.hostEnv.fqdn;
+        use = "external-web-service";
+        check_command = ["check_https" "mastodon.immae.eu" "/" "Mastodon</title>"];
+
+        servicegroups = "webstatus-webapps";
+        _webstatus_name = "Mastodon";
+        _webstatus_url = "https://mastodon.immae.eu/";
+      }
+    ];
   };
 }