65 lines
2.4 KiB
Nix
65 lines
2.4 KiB
Nix
{ config, pkgs, lib, ... }:
|
|
|
|
with lib;
|
|
|
|
{
|
|
services.nginx.enable = true;
|
|
|
|
services.nginx.virtualHosts = mkMerge [
|
|
(mkIf config.services.vaultwarden.enable {
|
|
"${config.module.hostName}-${config.module.vaultwarden.subdomain}" = {
|
|
listen = [{ addr = "0.0.0.0"; port = config.module.vaultwarden.externalPort; }];
|
|
locations."/" = {
|
|
proxyPass = "http://127.0.0.1:${toString config.module.vaultwarden.internalPort}";
|
|
extraConfig = ''
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
'';
|
|
};
|
|
};
|
|
})
|
|
|
|
(mkIf config.module.roundcube.enable {
|
|
"${config.module.hostName}-${config.module.roundcube.subdomain}" = {
|
|
listen = [{ addr = "0.0.0.0"; port = config.module.roundcube.port; }];
|
|
root = "${pkgs.roundcube}/public_html";
|
|
locations."/" = {
|
|
extraConfig = ''
|
|
index index.php index.html;
|
|
try_files $uri $uri/ /index.php?$args;
|
|
'';
|
|
};
|
|
locations."~ \\.php$" = {
|
|
extraConfig = ''
|
|
include ${pkgs.nginx}/conf/fastcgi_params;
|
|
fastcgi_pass unix:/run/phpfpm/roundcube.sock;
|
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
|
'';
|
|
};
|
|
};
|
|
})
|
|
(mkIf config.module.forgejo.enable {
|
|
"${config.module.hostName}-${config.module.forgejo.subdomain}" = {
|
|
listen = [{ addr = "0.0.0.0"; port = config.module.forgejo.externalPort; }];
|
|
locations."/" = {
|
|
proxyPass = "http://127.0.0.1:${toString config.module.forgejo.internalPort}";
|
|
extraConfig = ''
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
'';
|
|
};
|
|
};
|
|
})
|
|
|
|
];
|
|
|
|
networking.firewall.allowedTCPPorts = concatLists [
|
|
(if config.services.vaultwarden.enable then [ config.module.vaultwarden.externalPort ] else [])
|
|
(if config.services.roundcube.enable then [ config.module.roundcube.port ] else [])
|
|
(if config.services.forgejo.enable then [ config.module.forgejo.externalPort ] else [])
|
|
];
|
|
}
|