1 { config, pkgs, lib, name, ... }:
5 enable = lib.mkOption {
9 Whether to enable status app.
14 config = lib.mkIf config.myServices.status.enable {
15 secrets.keys."naemon-status/environment" = {
20 TOKENS=${builtins.concatStringsSep " " config.myEnv.monitoring.nrdp_tokens}
25 recommendedOptimisation = true;
26 recommendedGzipSettings = true;
27 recommendedProxySettings = true;
28 upstreams."netdata".servers = { "127.0.0.1:19999" = {}; };
29 upstreams."netdata".extraConfig = ''
32 virtualHosts."status.immae.eu" = {
33 acmeRoot = config.myServices.certificates.webroot;
36 locations."/".proxyPass = "http://unix:/run/naemon-status/socket.sock:/";
38 locations."= /netdata".return = "301 /netdata/";
39 locations."~ /netdata/(?<ndpath>.*)".extraConfig = ''
41 proxy_set_header Host $host;
43 proxy_set_header X-Forwarded-Host $host;
44 proxy_set_header X-Forwarded-Server $host;
45 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
46 proxy_http_version 1.1;
47 proxy_pass_request_headers on;
48 proxy_set_header Connection "keep-alive";
50 proxy_pass http://netdata/$ndpath$is_args$args;
58 security.acme.certs."${name}" = {
59 extraDomainNames = [ "status.immae.eu" ];
60 group = config.services.nginx.group;
63 myServices.certificates.enable = true;
64 networking.firewall.allowedTCPPorts = [ 80 443 ];
65 systemd.services.naemon-status = {
66 description = "Naemon status";
67 after = [ "network.target" ];
68 wantedBy = [ "multi-user.target" ];
71 EnvironmentFile = config.secrets.fullPaths."naemon-status/environment";
73 WorkingDirectory = "${./status}";
75 python = pkgs.python38.withPackages (p: [ p.gunicorn p.flask p.flask_login ]);
77 "${python}/bin/gunicorn -w4 --bind unix:/run/naemon-status/socket.sock app:app";
79 RuntimeDirectory = "naemon-status";
80 StandardOutput = "journal";
81 StandardError = "inherit";