1 { config, pkgs, lib, name, ... }:
5 enable = lib.mkOption {
9 Whether to enable status app.
14 config = lib.mkIf config.myServices.status.enable {
17 dest = "naemon-status/environment";
22 TOKENS=${builtins.concatStringsSep " " config.myEnv.monitoring.nrdp_tokens}
28 recommendedOptimisation = true;
29 recommendedGzipSettings = true;
30 recommendedProxySettings = true;
31 upstreams."netdata".servers = { "127.0.0.1:19999" = {}; };
32 upstreams."netdata".extraConfig = ''
35 virtualHosts."status.eban.bzh" = {
36 acmeRoot = config.myServices.certificates.webroot;
39 locations."/".proxyPass = "http://unix:/run/naemon-status/socket.sock:/";
41 virtualHosts."status.immae.eu" = {
42 acmeRoot = config.myServices.certificates.webroot;
45 locations."/".proxyPass = "http://unix:/run/naemon-status/socket.sock:/";
47 locations."= /netdata".return = "301 /netdata/";
48 locations."~ /netdata/(?<ndpath>.*)".extraConfig = ''
50 proxy_set_header Host $host;
52 proxy_set_header X-Forwarded-Host $host;
53 proxy_set_header X-Forwarded-Server $host;
54 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
55 proxy_http_version 1.1;
56 proxy_pass_request_headers on;
57 proxy_set_header Connection "keep-alive";
59 proxy_pass http://netdata/$ndpath$is_args$args;
67 security.acme.certs."${name}" = {
68 extraDomains."status.immae.eu" = null;
69 extraDomains."status.eban.bzh" = null;
70 user = config.services.nginx.user;
71 group = config.services.nginx.group;
74 myServices.certificates.enable = true;
75 networking.firewall.allowedTCPPorts = [ 80 443 ];
76 systemd.services.naemon-status = {
77 description = "Naemon status";
78 after = [ "network.target" ];
79 wantedBy = [ "multi-user.target" ];
82 EnvironmentFile = config.secrets.fullPaths."naemon-status/environment";
84 WorkingDirectory = "${./status}";
86 python = pkgs.python3.withPackages (p: [ p.gunicorn p.flask p.flask_login ]);
88 "${python}/bin/gunicorn -w4 --bind unix:/run/naemon-status/socket.sock app:app";
90 RuntimeDirectory = "naemon-status";
91 StandardOutput = "journal";
92 StandardError = "inherit";