nixos-config/config/services/akkoma/mediaproxy.nix

39 lines
1.1 KiB
Nix
Raw Normal View History

2022-11-05 20:26:45 +00:00
{
services.nginx = {
enable = true;
2022-11-19 19:37:00 +00:00
commonHttpConfig = "proxy_cache_path /var/cache/mediacache levels=2:2:2 keys_zone=akkoma_media_cache:25m inactive=1y use_temp_path=off min_free=10G;";
2022-11-05 20:26:45 +00:00
virtualHosts."mail.chir.rs".listen = [
{
addr = "127.0.0.1";
port = 24153;
}
];
virtualHosts."mediaproxy.int.chir.rs" = {
listen = [
{
addr = "127.0.0.1";
port = 24154;
}
];
extraConfig = ''
location ~ ^/(media|proxy) {
proxy_cache akkoma_media_cache;
2022-11-05 21:09:17 +00:00
proxy_cache_key $host$uri$is_args$args;
2022-11-05 20:26:45 +00:00
proxy_http_version 1.1;
proxy_cache_valid 206 301 302 304 1h;
proxy_cache_valid 200 1y;
proxy_cache_use_stale error timeout invalid_header updating;
proxy_ignore_client_abort on;
proxy_buffering on;
2022-11-05 21:12:27 +00:00
proxy_cache_lock on;
2022-11-05 20:26:45 +00:00
proxy_pass http://127.0.0.1:4000;
}
'';
};
};
systemd.tmpfiles.rules = [
"d '/var/cache/mediacache' 0750 nginx nginx - -"
];
2022-11-05 21:15:42 +00:00
systemd.services.nginx.serviceConfig.ReadWritePaths = ["/var/cache/mediacache"];
2022-11-05 20:26:45 +00:00
}