Rextract caddy config

This commit is contained in:
Jan Kremer 2026-03-27 07:37:25 +01:00
parent 11d6faae70
commit 0df36891b1
No known key found for this signature in database
4 changed files with 65 additions and 79 deletions

64
modules/nixos/caddy.nix Normal file
View file

@ -0,0 +1,64 @@
{
systemd.tmpfiles.rules = [
"d /var/www/jankremer.de 755 jan users -"
];
services.caddy = {
enable = true;
virtualHosts = {
"jankremer.de:8448".extraConfig = # caddyfile
''
reverse_proxy localhost:6167
'';
"jankremer.de".extraConfig = # caddyfile
''
handle /_matrix/* {
reverse_proxy localhost:6167
}
handle /.well-known/matrix/server {
header Content-Type application/json
respond `{"m.server": "jankremer.de:443"}` 200
}
handle /.well-known/matrix/client {
header Content-Type application/json
header Access-Control-Allow-Origin *
respond `{"m.homeserver": {"base_url": "https://jankremer.de"}}` 200
}
handle {
root * /var/www/jankremer.de
file_server
@static {
path *.css *.js *.woff2 *.woff *.ttf *.png *.jpg *.jpeg *.svg *.ico *.webp
}
header @static Cache-Control "public, max-age=31536000, immutable"
@html {
path *.html
}
header @html Cache-Control "no-cache"
}
handle_errors {
rewrite * /404.html
file_server
}
'';
"jankremer.eu".extraConfig = # caddyfile
''
redir https://jankremer.de{uri} permanent
'';
};
};
networking.firewall.allowedTCPPorts = [
80
443
8448
];
}

View file

@ -17,42 +17,4 @@
};
};
};
services.caddy = {
enable = true;
## Matrix federation
virtualHosts = {
"jankremer.de:8448" = {
extraConfig = # caddyfile
''
reverse_proxy localhost:6167
'';
};
"jankremer.de" = {
extraConfig = # caddyfile
''
handle /_matrix/* {
reverse_proxy localhost:6167
}
handle /.well-known/matrix/server {
header Content-Type application/json
respond `{"m.server": "jankremer.de:443"}` 200
}
handle /.well-known/matrix/client {
header Content-Type application/json
header Access-Control-Allow-Origin *
respond `{"m.homeserver": {"base_url": "https://jankremer.de"}}` 200
}
'';
};
};
};
networking.firewall.allowedTCPPorts = [
80
443
8448
];
}

View file

@ -1,40 +0,0 @@
{
systemd.tmpfiles.rules = [
"d /var/www/jankremer.de 755 jan users -"
];
services.caddy.virtualHosts = {
"jankremer.de".extraConfig = # caddyfile
''
handle {
root * /var/www/jankremer.de
file_server
@static {
path *.css *.js *.woff2 *.woff *.ttf *.png *.jpg *.jpeg *.svg *.ico *.webp
}
header @static Cache-Control "public, max-age=31536000, immutable"
@html {
path *.html
}
header @html Cache-Control "no-cache"
handle_errors {
rewrite * /404.html
file_server
}
}
'';
"jankremer.eu".extraConfig = # caddyfile
''
redir https://jankremer.de{uri} permanent
'';
};
networking.firewall.allowedTCPPorts = [
80
443
];
}