nixos-configuration/hosts/hetzner-vpn1/nginx.nix

58 lines
1.5 KiB
Nix
Raw Normal View History

2024-10-27 12:33:35 +01:00
{ pkgs, lib, ... }:
{
2024-10-26 18:15:50 +02:00
security.acme = {
acceptTerms = true;
defaults.email = "acme@zerforschen.plus";
};
security.pam.services.nginx.setEnvironment = false;
systemd.services.nginx.serviceConfig = {
2024-10-27 12:33:35 +01:00
SupplementaryGroups = [ "shadow" ];
2024-10-26 18:15:50 +02:00
};
services.nginx = {
enable = true;
2024-10-27 12:33:35 +01:00
additionalModules = [ pkgs.nginxModules.pam ];
2024-10-26 18:15:50 +02:00
recommendedProxySettings = true;
recommendedTlsSettings = true;
recommendedGzipSettings = true;
recommendedOptimisation = true;
2024-10-27 12:33:35 +01:00
virtualHosts =
let
servicesDomain = "services.zerforschen.plus";
mkServiceConfig = host: port: {
addSSL = true;
enableACME = true;
locations."/" = {
proxyPass = "http://${host}:${toString port}/";
extraConfig = ''
# bind to tailscale ip
proxy_bind 100.88.118.60;
# pam auth
limit_except OPTIONS {
auth_pam "Password Required";
auth_pam_service_name "nginx";
}
'';
};
2024-10-26 18:15:50 +02:00
};
2024-10-27 12:33:35 +01:00
pc2 = "vinzenz-pc2.donkey-pentatonic.ts.net";
in
{
"vscode.${servicesDomain}" = lib.mkMerge [
(mkServiceConfig pc2 8542)
{ locations."/".proxyWebsockets = true; }
];
"preon-app.${servicesDomain}" = mkServiceConfig pc2 8543;
"preon-api.${servicesDomain}" = mkServiceConfig pc2 8544;
2024-10-26 18:15:50 +02:00
};
};
2024-10-27 12:33:35 +01:00
networking.firewall.allowedTCPPorts = [
80
443
];
2024-10-26 18:15:50 +02:00
}