From cc0761579f4a66ad4876dbfc1f4262a00995e56a Mon Sep 17 00:00:00 2001 From: Astro Date: Tue, 14 Apr 2020 20:58:04 +0200 Subject: [PATCH] freifunk: add nginx --- hosts/containers/freifunk/assets/index.html | 9 ++++ .../freifunk/assets/sysinfo-json.cgi | 50 +++++++++++++++++++ hosts/containers/freifunk/configuration.nix | 48 ++++++++++++++++++ krops.nix | 1 + 4 files changed, 108 insertions(+) create mode 100644 hosts/containers/freifunk/assets/index.html create mode 100644 hosts/containers/freifunk/assets/sysinfo-json.cgi diff --git a/hosts/containers/freifunk/assets/index.html b/hosts/containers/freifunk/assets/index.html new file mode 100644 index 00000000..4d2028c2 --- /dev/null +++ b/hosts/containers/freifunk/assets/index.html @@ -0,0 +1,9 @@ +

Chaos Computer Club Dresden

+

Router zu Freifunk Dresden

+ + + diff --git a/hosts/containers/freifunk/assets/sysinfo-json.cgi b/hosts/containers/freifunk/assets/sysinfo-json.cgi new file mode 100644 index 00000000..92dff0ae --- /dev/null +++ b/hosts/containers/freifunk/assets/sysinfo-json.cgi @@ -0,0 +1,50 @@ +{ + "version": "15", + "timestamp": "1586882346", + "data": { + "firmware": { + "version": "0.0.0", + "DISTRIB_ID": "NixOS", + "DISTRIB_RELEASE": "20.03", + "DISTRIB_REVISION": "", + "DISTRIB_CODENAME": "", + "DISTRIB_TARGET": "x86_64", + "DISTRIB_DESCRIPTION": "NixOS 20.03" + }, + "system": { + "uptime": "0 0", + "uname": "Linux 5.3.18", + "nameserver": [ + ], + "date": "Tue Apr 14 18:39:06 CEST 2020", + "cpuinfo": "Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz", + "cpucount": "40", + "bmxd": "bmxd", + "essid": "ZW public", + "node_type": "router", + "splash": 0, + "email_notification": 0, + "autoupdate": 0, + "available_flash_size": "16T", + "bmxd_restart_counter": 0 + }, + "common": { + "city": "Dresden", + "node": "51073", + "domain": "freifunk-dresden.de", + "ip": "10.200.200.74", + "network_id": "1206" + }, + "gps": { + "latitude": 51.0810624, + "longitude": 13.7285866, + "altitude": 100 + }, + "contact": { + "name": "C3D2", + "location": "Zentralwerk Haus B Souterrain", + "email": "astro%40spaceboyz.net", + "note": "" + } + } +} diff --git a/hosts/containers/freifunk/configuration.nix b/hosts/containers/freifunk/configuration.nix index ae2d5b2e..85615a96 100644 --- a/hosts/containers/freifunk/configuration.nix +++ b/hosts/containers/freifunk/configuration.nix @@ -196,6 +196,54 @@ in { ''; }; + services.nginx = { + enable = true; + recommendedOptimisation = true; + recommendedGzipSettings = true; + + virtualHosts = + let + aliasFile = path: { + alias = path; + extraConfig = '' + etag off; + add_header etag "\"${builtins.substring 11 32 path}\""; + ''; + }; + in { + "c3d2.ffdd" = { + default = true; + root = ; + locations = { + "/".index = "index.html"; + "/sysinfo-json.cgi".extraConfig = '' + add_header Content-Type "application/json;charset=UTF-8"; + ''; + }; + }; + "storage.hq.c3d2.ffdd" = { + locations = { + "/".proxyPass = "http://storage.hq.c3d2.de/"; + }; + }; + "grafana.hq.c3d2.ffdd" = { + locations = { + "/" = { + proxyPass = "https://grafana.hq.c3d2.de/"; + extraConfig = '' + proxy_ssl_server_name on; + ''; + }; + }; + }; + "influxdb.hq.c3d2.ffdd" = { + locations = { + "/".proxyPass = "http://grafana.hq.c3d2.de:8086/"; + }; + }; + }; + }; + # This value determines the NixOS release with which your system is to be # compatible, in order to avoid breaking some software such as database # servers. You should change this only after NixOS release notes say you diff --git a/krops.nix b/krops.nix index f9ad4e28..6e31df4d 100644 --- a/krops.nix +++ b/krops.nix @@ -16,6 +16,7 @@ let url = "https://github.com/NixOS/nixpkgs.git"; }; nixos-config.file = toString (./hosts + "/${path}/configuration.nix"); + this-host.file = toString (./hosts + "/${path}"); lib.file = toString ./lib; secrets.file = toString ./secrets; "host-registry.nix".file = toString ./host-registry.nix;