nixos-config/modules/zabbix-server.nix

71 lines
1.9 KiB
Nix
Raw Normal View History

2022-09-25 00:31:22 +02:00
{ pkgs, lib, ... }:
let
2023-01-31 11:29:05 +01:00
cfg = import ./vars.nix;
db = cfg.zabbix.db;
db_host = cfg.podman.hostIP;
port = cfg.zabbix.port;
domain = cfg.zabbix.domain;
2023-01-20 10:36:33 +01:00
server_ip = "10.88.1.0";
web_ip = "10.88.1.1";
2022-09-25 00:31:22 +02:00
in
{
services.postgresql = {
ensureDatabases = [ db ];
ensureUsers = [
{
name = db;
ensurePermissions = {
"DATABASE ${db}" = "ALL PRIVILEGES";
};
}
];
2022-12-14 13:54:38 +01:00
extraPlugins = [
2022-12-14 14:25:18 +01:00
(pkgs.callPackage ../packages/timescaledb/timescaledb.nix {})
2022-12-14 13:54:38 +01:00
];
2022-09-25 00:31:22 +02:00
settings = {
shared_preload_libraries = "timescaledb";
};
2023-01-20 10:36:33 +01:00
authentication = "host ${db} ${db} 10.88.0.0/16 md5";
2022-09-25 00:31:22 +02:00
};
2023-01-20 10:36:33 +01:00
virtualisation.oci-containers.containers.zabbix-server = {
2023-01-31 11:29:05 +01:00
image = "docker.io/zabbix/zabbix-server-pgsql:alpine-6.2-latest";
2023-01-20 10:36:33 +01:00
environment = {
DB_SERVER_HOST = db_host;
POSTGRES_USER = db;
2022-09-25 00:31:22 +02:00
};
2023-01-20 10:36:33 +01:00
environmentFiles = [ /etc/nixos/keys/zabbix-env ];
2023-01-31 11:29:05 +01:00
extraOptions = cfg.podman.extraOptions ++ [ "--ip=${server_ip}" ];
2022-09-25 00:31:22 +02:00
};
2023-01-20 10:36:33 +01:00
virtualisation.oci-containers.containers.zabbix-web = {
2023-01-31 11:29:05 +01:00
image = "docker.io/zabbix/zabbix-web-nginx-pgsql:alpine-6.2-latest";
2023-01-20 10:36:33 +01:00
environment = {
DB_SERVER_HOST = db_host;
POSTGRES_USER = db;
ZBX_SERVER_HOST = server_ip;
2023-01-31 11:29:05 +01:00
ZBX_SERVER_NAME = "Superbly Managed Networks and Hosting";
2023-01-20 10:36:33 +01:00
PHP_TZ = "Europe/Berlin";
2022-09-25 00:31:22 +02:00
};
2023-01-20 10:36:33 +01:00
environmentFiles = [ /etc/nixos/keys/zabbix-env ];
2023-01-31 11:29:05 +01:00
extraOptions = cfg.podman.extraOptions ++ [ "--ip=${web_ip}" ];
2023-01-20 10:36:33 +01:00
ports = [ "${port}:8080" ];
2022-09-25 00:31:22 +02:00
};
services.nginx.virtualHosts.${domain} = {
forceSSL = true;
enableACME = true;
locations."/" = {
proxyPass = "http://localhost:${port}";
};
2022-10-30 15:51:48 +01:00
extraConfig = ''
access_log /var/log/nginx/${domain}_access.log;
error_log /var/log/nginx/${domain}_error.log;
'';
2022-09-25 00:31:22 +02:00
};
2023-01-31 11:29:05 +01:00
networking.firewall.interfaces.podman0.allowedTCPPorts = [ 5432 10050 ];
2022-09-25 00:31:22 +02:00
}
# vim: set et ts=2 sw=2 ai: