2022-11-29 14:51:54 +00:00
|
|
|
{ config, secret, ... }:
|
2022-11-29 14:17:23 +00:00
|
|
|
|
2022-11-29 14:51:54 +00:00
|
|
|
let
|
|
|
|
web-domain = "mastodon.kempkens.io";
|
2022-11-29 15:51:16 +00:00
|
|
|
|
2022-11-29 15:52:49 +00:00
|
|
|
nginx-extra-proxy-settings = ''
|
|
|
|
proxy_set_header Host $host;
|
2022-11-29 16:45:06 +00:00
|
|
|
proxy_set_header X-Forwarded-For $http_x_forwarded_for;
|
2022-11-29 15:52:49 +00:00
|
|
|
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
|
|
|
|
proxy_set_header X-Forwarded-Host $host;
|
|
|
|
proxy_set_header X-Forwarded-Server $host;
|
2022-12-20 16:47:13 +00:00
|
|
|
|
|
|
|
proxy_force_ranges on;
|
2022-11-29 15:52:49 +00:00
|
|
|
'';
|
2022-11-29 14:51:54 +00:00
|
|
|
in
|
2022-11-29 14:17:23 +00:00
|
|
|
{
|
|
|
|
services.mastodon = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
configureNginx = false;
|
|
|
|
|
|
|
|
localDomain = "kempkens.io";
|
|
|
|
|
|
|
|
streamingPort = 55000;
|
|
|
|
webPort = 55001;
|
|
|
|
sidekiqPort = 55002;
|
2022-11-29 23:13:09 +00:00
|
|
|
enableUnixSocket = true;
|
|
|
|
|
|
|
|
sidekiqThreads = 12;
|
2022-11-29 14:17:23 +00:00
|
|
|
|
2022-11-29 14:54:13 +00:00
|
|
|
trustedProxy = "127.0.0.1";
|
2022-11-29 14:17:23 +00:00
|
|
|
|
|
|
|
vapidPublicKeyFile = "/var/lib/mastodon/secrets/vapid-public-key";
|
|
|
|
secretKeyBaseFile = "/var/lib/mastodon/secrets/secret-key-base";
|
|
|
|
otpSecretFile = "/var/lib/mastodon/secrets/otp-secret";
|
|
|
|
vapidPrivateKeyFile = "/var/lib/mastodon/secrets/vapid-private-key";
|
|
|
|
|
|
|
|
database = {
|
|
|
|
createLocally = false;
|
|
|
|
host = "10.99.99.3";
|
|
|
|
port = 5432;
|
|
|
|
name = "mastodon";
|
|
|
|
inherit (secret.mastodon.database) user;
|
|
|
|
inherit (secret.mastodon.database) passwordFile;
|
|
|
|
};
|
|
|
|
|
|
|
|
redis = {
|
|
|
|
createLocally = false;
|
|
|
|
host = "10.99.99.3";
|
|
|
|
port = 6379;
|
|
|
|
};
|
|
|
|
|
2022-12-23 16:08:24 +00:00
|
|
|
elasticsearch = {
|
|
|
|
host = "10.99.99.3";
|
|
|
|
port = 9200;
|
|
|
|
};
|
2022-11-29 14:17:23 +00:00
|
|
|
|
|
|
|
smtp = {
|
|
|
|
createLocally = false;
|
|
|
|
authenticate = true;
|
|
|
|
host = "smtp.mailgun.org";
|
2022-11-29 16:03:25 +00:00
|
|
|
port = 587;
|
2022-11-29 14:17:23 +00:00
|
|
|
fromAddress = "mastodon@mg.kempkens.io";
|
|
|
|
inherit (secret.mastodon.smtp) user;
|
|
|
|
inherit (secret.mastodon.smtp) passwordFile;
|
|
|
|
};
|
|
|
|
|
|
|
|
automaticMigrations = true;
|
|
|
|
|
|
|
|
mediaAutoRemove = {
|
|
|
|
enable = true;
|
|
|
|
startAt = "daily";
|
2022-12-01 21:48:43 +00:00
|
|
|
olderThanDays = 14;
|
2022-11-29 14:17:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extraConfig = {
|
2022-11-29 14:51:54 +00:00
|
|
|
WEB_DOMAIN = web-domain;
|
2022-12-23 16:08:24 +00:00
|
|
|
|
|
|
|
ES_USER = secret.mastodon.elasticsearch.user;
|
|
|
|
ES_PASS = secret.mastodon.elasticsearch.password;
|
2022-12-26 00:26:33 +00:00
|
|
|
|
|
|
|
S3_ENABLED = true;
|
|
|
|
S3_BUCKET = secret.mastodon.s3.bucket;
|
|
|
|
AWS_ACCESS_KEY_ID = secret.mastodon.s3.accessKeyId;
|
|
|
|
AWS_SECRET_ACCESS_KEY = secret.mastodon.s3.secretAccessKey;
|
|
|
|
S3_PROTOCOL = "https";
|
|
|
|
S3_REGION = secret.mastodon.s3.region;
|
|
|
|
S3_ENDPOINT = secret.mastodon.s3.endpoint;
|
|
|
|
S3_ALIAS_HOST = secret.mastodon.s3.hostname;
|
|
|
|
S3_HOSTNAME = secret.mastodon.s3.hostname;
|
2022-11-29 14:51:54 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
services.nginx = {
|
|
|
|
enable = true;
|
|
|
|
virtualHosts."${web-domain}" = {
|
|
|
|
root = "${config.services.mastodon.package}/public/";
|
|
|
|
forceSSL = false;
|
|
|
|
enableACME = false;
|
|
|
|
|
|
|
|
locations."/system/".alias = "/var/lib/mastodon/public-system/";
|
|
|
|
|
|
|
|
locations."/" = {
|
|
|
|
tryFiles = "$uri @proxy";
|
|
|
|
};
|
|
|
|
|
|
|
|
locations."@proxy" = {
|
2022-11-29 23:13:09 +00:00
|
|
|
proxyPass = "http://unix:/run/mastodon-web/web.socket";
|
2022-11-29 14:51:54 +00:00
|
|
|
proxyWebsockets = true;
|
2022-11-29 15:51:16 +00:00
|
|
|
extraConfig = nginx-extra-proxy-settings;
|
2022-11-29 14:51:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
locations."/api/v1/streaming/" = {
|
2022-11-29 23:13:09 +00:00
|
|
|
proxyPass = "http://unix:/run/mastodon-streaming/streaming.socket";
|
2022-11-29 14:51:54 +00:00
|
|
|
proxyWebsockets = true;
|
2022-11-29 15:51:16 +00:00
|
|
|
extraConfig = nginx-extra-proxy-settings;
|
2022-11-29 14:51:54 +00:00
|
|
|
};
|
2022-11-29 14:17:23 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-11-29 23:16:26 +00:00
|
|
|
users.groups.mastodon.members = [ config.services.nginx.user ];
|
2022-11-29 20:28:18 +00:00
|
|
|
|
2022-11-29 14:58:30 +00:00
|
|
|
networking.firewall.allowedTCPPorts = [ 80 ];
|
2022-11-29 14:17:23 +00:00
|
|
|
}
|