infrastructure/hosts/mirror.lewd.wtf/mirror/default.nix

46 lines
1.0 KiB
Nix

{ config, ... }:
{
imports = [
./xslt_template.nix
];
networking.firewall.allowedTCPPorts = [ 80 443 ];
services.nginx = {
enable = true;
virtualHosts."mirror.lewd.wtf" = {
serverName = "${config.variables.hostName}.${config.variables.domain}";
enableACME = true;
forceSSL = true;
root = "/var/www/mirror/mirror/";
locations = {
"/" = {
extraConfig = ''
if ($arg_format = "json") {
rewrite ^ /json$request_uri last;
}
autoindex on;
autoindex_format xml;
xslt_stylesheet /etc/nginx/mirror.xslt dirname='$1';
'';
};
"/json/" = {
alias = "/var/www/mirror/mirror/";
extraConfig = ''
autoindex on;
autoindex_format json;
'';
};
"/private/" = {
alias = "/var/www/mirror/private/";
extraConfig = ''
autoindex off;
'';
};
"~ \.xml$" = {
};
};
};
};
}