| 1 | { config, ... }: |
| 2 | |
| 3 | { |
| 4 | networking.firewall.allowedTCPPorts = [ |
| 5 | 80 |
| 6 | 443 |
| 7 | ]; |
| 8 | |
| 9 | services.nginx = { |
| 10 | enable = true; |
| 11 | recommendedProxySettings = true; |
| 12 | |
| 13 | eventsConfig = '' |
| 14 | worker_connections 4096; |
| 15 | ''; |
| 16 | |
| 17 | virtualHosts."monitoring.nixos.org" = { |
| 18 | enableACME = true; |
| 19 | forceSSL = true; |
| 20 | default = true; |
| 21 | locations."/".return = "302 https://status.nixos.org"; |
| 22 | locations."~ ^/prometheus/?(?<action>[^\\s]+)" = { |
| 23 | return = "301 https://prometheus.nixos.org/$action$is_args$args"; |
| 24 | # TODO: Remove after https://github.com/NixOS/nixos-status/pull/21 |
| 25 | extraConfig = '' |
| 26 | add_header Access-Control-Allow-Origin "*" always; |
| 27 | ''; |
| 28 | }; |
| 29 | locations."~ ^/grafana/?(?<action>[^\\s]+)".return = |
| 30 | "301 https://grafana.nixos.org/$action$is_args$args"; |
| 31 | }; |
| 32 | |
| 33 | virtualHosts."prometheus.nixos.org" = { |
| 34 | enableACME = true; |
| 35 | forceSSL = true; |
| 36 | locations."/" = { |
| 37 | proxyPass = "http://${config.services.prometheus.listenAddress}:${toString config.services.prometheus.port}"; |
| 38 | }; |
| 39 | }; |
| 40 | |
| 41 | virtualHosts."grafana.nixos.org" = { |
| 42 | enableACME = true; |
| 43 | forceSSL = true; |
| 44 | locations."/" = { |
| 45 | proxyPass = "http://unix:${config.services.grafana.settings.server.socket}"; |
| 46 | proxyWebsockets = true; |
| 47 | }; |
| 48 | }; |
| 49 | }; |
| 50 | } |