Mastodon: Difference between revisions

imported>Nix
m add Software/Applications subcategory
imported>Cab404
Added instructions for Caddy
Line 1: Line 1:
== Using Caddy as a server  ==
Use the following template:
<syntaxHighlight lang=nix>
services = {
  caddy = {
    enable = true;
    virtualHosts = {
   
      # Don't forget to change the host!
      "<your-server-host>" = {
        extraConfig = ''
          handle_path /system/* {
              file_server * {
                  root /var/lib/mastodon/public-system
              }
          }
          handle /api/v1/streaming/* {
              reverse_proxy  unix//run/mastodon-streaming/streaming.socket
          }
          file_server * {
              root ${pkgs.mastodon}/public
              pass_thru
          }
          reverse_proxy * unix//run/mastodon-web/web.socket
          handle_errors {
              root * ${pkgs.mastodon}/public
              rewrite 500.html
              file_server
          }
          encode gzip
          header /* {
              Strict-Transport-Security "max-age=31536000;"
          }
          header /emoji/* Cache-Control "public, max-age=31536000, immutable"
          header /packs/* Cache-Control "public, max-age=31536000, immutable"
          header /system/accounts/avatars/* Cache-Control "public, max-age=31536000, immutable"
          header /system/media_attachments/files/* Cache-Control "public, max-age=31536000, immutable"
        '';
    };
  };
};
# Caddy requires files and socket access
users.users.caddy.extraGroups = [ "mastodon" ];
</syntaxHighlight>


== Hints for running in your local network for testing ==
== Hints for running in your local network for testing ==