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 extraDomains."status.immae.eu" = null;
60 user = config.services.nginx.user;
61 group = config.services.nginx.group;
64 myServices.certificates.enable = true;
65 networking.firewall.allowedTCPPorts = [ 80 443 ];
66 systemd.services.naemon-status = {
67 description = "Naemon status";
68 after = [ "network.target" ];
69 wantedBy = [ "multi-user.target" ];
72 EnvironmentFile = config.secrets.fullPaths."naemon-status/environment";
74 WorkingDirectory = "${./status}";
76 python = pkgs.python3.withPackages (p: [ p.gunicorn p.flask p.flask_login ]);
78 "${python}/bin/gunicorn -w4 --bind unix:/run/naemon-status/socket.sock app:app";
80 RuntimeDirectory = "naemon-status";
81 StandardOutput = "journal";
82 StandardError = "inherit";