vpn2: split nginx config

This commit is contained in:
Vinzenz Schroeter 2026-01-04 20:17:22 +01:00 committed by müde
parent 24b0fcf632
commit 040bb41705
3 changed files with 50 additions and 49 deletions

View file

@ -0,0 +1,43 @@
{ pkgs, ... }:
let
blog-domain-socket = "/run/nginx/blog.sock";
anubis-domain-socket = "/run/anubis/anubis-main/anubis.sock";
anubis-metrics-socket = "/run/anubis/anubis-main/anubis-metrics.sock";
in
{
systemd.services = {
nginx.serviceConfig.SupplementaryGroups = [ "anubis" ];
anubis-main.serviceConfig.SupplementaryGroups = [ "nginx" ];
};
services = {
nginx.virtualHosts = {
"zerforschen.plus" = {
addSSL = true;
enableACME = true;
locations = {
"/_metrics".proxyPass = "http://unix:" + anubis-metrics-socket + ":/metrics";
"/".proxyPass = "http://unix:" + anubis-domain-socket;
};
};
"blog-in-anubis" = {
root = pkgs.zerforschen-plus-content;
listen = [
{
addr = "unix:" + blog-domain-socket;
}
];
};
};
anubis.instances.main = {
enable = true;
settings = {
BIND = anubis-domain-socket;
TARGET = "unix://" + blog-domain-socket;
METRICS_BIND = anubis-metrics-socket;
};
};
};
}

View file

@ -3,6 +3,7 @@
./hardware.nix
./nginx.nix
./headscale.nix
./blog.nix
];
config = {

View file

@ -1,62 +1,19 @@
{ pkgs, ... }:
let
blog-domain-socket = "/run/nginx/blog.sock";
anubis-domain-socket = "/run/anubis/anubis-main/anubis.sock";
anubis-metrics-socket = "/run/anubis/anubis-main/anubis-metrics.sock";
in
{
security.acme = {
acceptTerms = true;
defaults.email = "acme@zerforschen.plus";
};
systemd.services = {
nginx.serviceConfig.SupplementaryGroups = [ "anubis" ];
anubis-main.serviceConfig.SupplementaryGroups = [ "nginx" ];
};
services = {
nginx = {
enable = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
recommendedGzipSettings = true;
recommendedOptimisation = true;
virtualHosts = {
"zerforschen.plus" = {
addSSL = true;
enableACME = true;
locations = {
"/_metrics".proxyPass = "http://unix:" + anubis-metrics-socket + ":/metrics";
"/".proxyPass = "http://unix:" + anubis-domain-socket;
};
};
"blog-in-anubis" = {
root = pkgs.zerforschen-plus-content;
listen = [
{
addr = "unix:" + blog-domain-socket;
}
];
};
};
};
anubis.instances.main = {
enable = true;
settings = {
BIND = anubis-domain-socket;
TARGET = "unix://" + blog-domain-socket;
METRICS_BIND = anubis-metrics-socket;
};
};
services.nginx = {
enable = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
recommendedGzipSettings = true;
recommendedOptimisation = true;
};
networking.firewall.allowedTCPPorts = [
80
443
5201
];
}