2024-08-29 03:26:04 +02:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
assets,
|
|
|
|
...
|
|
|
|
}:
|
2023-12-22 20:28:52 +01:00
|
|
|
with lib;
|
|
|
|
{
|
|
|
|
options.components.network.nginx.enable = mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
default = config.components.network.enable;
|
|
|
|
};
|
|
|
|
|
2024-04-12 20:56:42 +02:00
|
|
|
options.components.network.nginx.landingpage.enable = mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
default = config.components.network.nginx.enable;
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkMerge [
|
|
|
|
(mkIf (config.components.network.nginx.enable) {
|
|
|
|
|
|
|
|
environment.systemPackages = [
|
|
|
|
pkgs.nginx-config-formatter
|
2024-08-29 03:26:04 +02:00
|
|
|
(pkgs.writers.writePython3Bin "nginx-show-config" {
|
|
|
|
flakeIgnore = [
|
|
|
|
"E265"
|
|
|
|
"E225"
|
|
|
|
"W292"
|
|
|
|
];
|
|
|
|
} (lib.fileContents "${assets}/nginx-show-config.py"))
|
2024-04-12 20:56:42 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
security.acme.defaults.email = "contact@ingolf-wagner.de";
|
|
|
|
security.acme.acceptTerms = true;
|
2024-02-23 09:39:08 +01:00
|
|
|
|
2024-04-12 20:56:42 +02:00
|
|
|
services.nginx = {
|
|
|
|
|
|
|
|
# Use recommended settings
|
|
|
|
recommendedGzipSettings = lib.mkDefault true;
|
|
|
|
recommendedOptimisation = lib.mkDefault true;
|
|
|
|
recommendedProxySettings = lib.mkDefault true;
|
|
|
|
recommendedTlsSettings = lib.mkDefault true;
|
|
|
|
|
|
|
|
# for loki logging
|
|
|
|
commonHttpConfig = ''
|
2024-05-15 17:11:41 +02:00
|
|
|
log_format logfmt
|
|
|
|
'timestamp="$time_iso8601" '
|
|
|
|
'facility="nginx" '
|
|
|
|
'src_addr="$remote_addr" '
|
|
|
|
'body_bytes_sent="$body_bytes_sent" '
|
|
|
|
'request_time="$request_time" '
|
|
|
|
'response_status="$status" '
|
2024-04-12 20:56:42 +02:00
|
|
|
'request_method="$request_method" '
|
2024-05-15 17:11:41 +02:00
|
|
|
'request="$request" '
|
2024-04-12 20:56:42 +02:00
|
|
|
'host="$host" '
|
|
|
|
'upstream_cache_status="$upstream_cache_status" '
|
|
|
|
'upstream_addr="$upstream_addr" '
|
|
|
|
'http_x_forwarded_for="$http_x_forwarded_for" '
|
|
|
|
'http_referrer="$http_referer" '
|
2024-05-15 17:11:41 +02:00
|
|
|
'http_user_agent="$http_user_agent" ';
|
|
|
|
|
|
|
|
log_format json_combined escape=json
|
|
|
|
'{'
|
2024-06-21 15:45:56 +02:00
|
|
|
'"timestamp":"$time_iso8601",'
|
|
|
|
'"facility":"nginx",'
|
|
|
|
'"src_addr":"$remote_addr",'
|
2024-05-15 17:11:41 +02:00
|
|
|
'"body_bytes_sent":"$body_bytes_sent",'
|
|
|
|
'"request_time":"$request_time",'
|
2024-06-21 15:45:56 +02:00
|
|
|
'"response_status":"$status",'
|
|
|
|
'"request_method":"$request_method",'
|
|
|
|
'"request":"$request",'
|
|
|
|
'"host":"$host",'
|
|
|
|
'"upstream_cache_status":"$upstream_cache_status",'
|
|
|
|
'"upstream_addr":"$upstream_addr",'
|
|
|
|
'"http_x_forwarded_for":"$http_x_forwarded_for",'
|
2024-05-15 17:11:41 +02:00
|
|
|
'"http_referrer":"$http_referer",'
|
|
|
|
'"http_user_agent":"$http_user_agent"'
|
|
|
|
'}';
|
|
|
|
|
2024-04-12 20:56:42 +02:00
|
|
|
# log to local journald
|
2024-05-15 17:11:41 +02:00
|
|
|
access_log syslog:server=unix:/dev/log,nohostname logfmt;
|
2024-04-12 20:56:42 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
services.nginx.package = pkgs.nginxMainline;
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
(mkIf (config.components.network.nginx.landingpage.enable) {
|
|
|
|
|
|
|
|
services.nginx.virtualHosts."${config.networking.hostName}.private" = {
|
|
|
|
default = lib.mkDefault true;
|
|
|
|
locations."/" = {
|
|
|
|
root = pkgs.landingpage.override {
|
2024-06-11 13:17:37 +02:00
|
|
|
jsonConfig =
|
|
|
|
let
|
2024-08-29 03:26:04 +02:00
|
|
|
entry =
|
|
|
|
{
|
|
|
|
machine,
|
|
|
|
items ? [ ],
|
|
|
|
}:
|
2024-06-11 13:17:37 +02:00
|
|
|
{
|
|
|
|
text = machine;
|
|
|
|
items = [
|
|
|
|
{
|
|
|
|
label = "Syncthing";
|
|
|
|
href = "http://${machine}.private:8384/";
|
|
|
|
image = "https://media.giphy.com/media/JoyU4vuzwj6ZA7Ging/giphy.gif";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
label = "netdata";
|
|
|
|
href = "http://${machine}.private:19999/";
|
|
|
|
image = "https://media.giphy.com/media/BkjdN6MQCDPaw/giphy.gif";
|
|
|
|
}
|
|
|
|
] ++ items;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
[
|
|
|
|
{ title = "System Links"; }
|
2024-06-12 10:14:11 +02:00
|
|
|
(entry {
|
|
|
|
machine = "orbi";
|
|
|
|
items = [
|
2024-06-11 13:17:37 +02:00
|
|
|
{
|
|
|
|
label = "Jellyfin";
|
|
|
|
href = "http://flix.ingolf-wagner.de/";
|
|
|
|
image = "https://media.giphy.com/media/fyLi0OuWysotq/giphy.gif";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
label = "PhotoPrism";
|
|
|
|
href = "http://10.100.0.1:2342/";
|
|
|
|
image = "https://media.giphy.com/media/fyLi0OuWysotq/giphy.gif";
|
|
|
|
}
|
2024-07-17 21:48:22 +02:00
|
|
|
{
|
|
|
|
label = "Build Bot";
|
|
|
|
href = "http://orbi.private:8010";
|
|
|
|
image = "https://i.giphy.com/media/v1.Y2lkPTc5MGI3NjExd2gxZDg4Mm92c280OWxlZXJoZ3V6MWozamI5c3M2dnd1M3pma2lydiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/UqcFByCQIOloWRXUxs/giphy.gif";
|
|
|
|
}
|
2024-06-12 10:14:11 +02:00
|
|
|
];
|
|
|
|
})
|
|
|
|
(entry {
|
|
|
|
machine = "chungus";
|
|
|
|
items = [
|
2024-06-11 13:17:37 +02:00
|
|
|
{
|
|
|
|
label = "Grafana";
|
|
|
|
href = "http://grafana.chungus.private/explore";
|
|
|
|
image = "https://raw.githubusercontent.com/cncf/landscape/master/hosted_logos/grafana-loki.svg";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
label = "Jellyfin";
|
|
|
|
href = "http://chungus:8096/";
|
|
|
|
image = "https://media.giphy.com/media/fyLi0OuWysotq/giphy.gif";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
label = "HomeAssistant";
|
|
|
|
href = "http://chungus.private:8123/";
|
|
|
|
image = "https://media.giphy.com/media/fyLi0OuWysotq/giphy.gif";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
label = "Zigbee2Mqtt";
|
|
|
|
href = "http://chungus.private:9666/";
|
|
|
|
image = "https://media.giphy.com/media/fyLi0OuWysotq/giphy.gif";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
label = "Kitchen";
|
|
|
|
href = "http://192.168.178.101/";
|
|
|
|
image = "https://i.giphy.com/3o7TKsrMIW65QT7VWo.webp";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
label = "Living Room";
|
|
|
|
href = "http://192.168.178.102/";
|
|
|
|
image = "https://i.giphy.com/3o7TKsrMIW65QT7VWo.webp";
|
|
|
|
}
|
2024-06-12 10:14:11 +02:00
|
|
|
];
|
|
|
|
})
|
2024-06-11 13:17:37 +02:00
|
|
|
(entry { machine = "cherry"; })
|
2024-10-19 09:24:26 +02:00
|
|
|
#(entry { machine = "cream"; })
|
2024-06-11 13:17:37 +02:00
|
|
|
(entry { machine = "mobi"; })
|
|
|
|
(entry { machine = "bobi"; })
|
|
|
|
{
|
|
|
|
title = "Various Links";
|
|
|
|
items = [
|
|
|
|
{
|
|
|
|
label = "Terrapen";
|
|
|
|
href = "http://192.168.178.31/";
|
|
|
|
image = "https://i.giphy.com/W08brEWFt7EpA5y2jI.webp";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
label = "Hetzner Cloud";
|
|
|
|
href = "https://console.hetzner.cloud/projects";
|
2024-08-29 03:26:04 +02:00
|
|
|
image = "https://media.giphy.com/media/NECZ8crkbXR0k/giphy.gif";
|
2024-06-11 13:17:37 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
label = "Cups";
|
|
|
|
href = "http://localhost:631/";
|
2024-08-29 03:26:04 +02:00
|
|
|
image = "https://media.giphy.com/media/7hU7x4GPurk2c/giphy.gif";
|
2024-06-11 13:17:37 +02:00
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
{
|
|
|
|
text = "NixOS Links";
|
|
|
|
items = [
|
|
|
|
{
|
|
|
|
label = "NixOS Manual";
|
|
|
|
href = "https://nixos.org/nixos/manual/";
|
2024-08-29 03:26:04 +02:00
|
|
|
image = "https://media.giphy.com/media/dsdVyKkSqccEzoPufX/giphy.gif";
|
2024-06-11 13:17:37 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
label = "Nixpkgs Manual";
|
|
|
|
href = "https://nixos.org/nixpkgs/manual/";
|
2024-08-29 03:26:04 +02:00
|
|
|
image = "https://media.giphy.com/media/dsdVyKkSqccEzoPufX/giphy.gif";
|
2024-06-11 13:17:37 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
label = "NixOS Reference";
|
2024-08-29 03:26:04 +02:00
|
|
|
href = "https://storage.googleapis.com/files.tazj.in/nixdoc/manual.html#sec-functions-library";
|
|
|
|
image = "https://media.giphy.com/media/LkjlH3rVETgsg/giphy.gif";
|
2024-06-11 13:17:37 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
label = "Nix Packages";
|
|
|
|
href = "https://nixos.org/nixos/packages.html";
|
2024-08-29 03:26:04 +02:00
|
|
|
image = "https://media.giphy.com/media/l2YWlohvjPnsvkdEc/giphy.gif";
|
2024-06-11 13:17:37 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
label = "NixOS Language specific helpers";
|
2024-08-29 03:26:04 +02:00
|
|
|
href = "https://nixos.wiki/wiki/Language-specific_package_helpers";
|
|
|
|
image = "https://media.giphy.com/media/LkjlH3rVETgsg/giphy.gif";
|
2024-06-11 13:17:37 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
label = "NixOS Weekly";
|
|
|
|
href = "https://weekly.nixos.org/";
|
2024-08-29 03:26:04 +02:00
|
|
|
image = "https://media.giphy.com/media/lXiRLb0xFzmreM8k8/giphy.gif";
|
2024-06-11 13:17:37 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
label = "NixOS Security";
|
|
|
|
href = "https://broken.sh/";
|
2024-08-29 03:26:04 +02:00
|
|
|
image = "https://media.giphy.com/media/BqILAHjH1Ttm0/giphy.gif";
|
2024-06-11 13:17:37 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
label = "NixOS RFCs";
|
|
|
|
href = "https://github.com/NixOS/rfcs/";
|
2024-08-29 03:26:04 +02:00
|
|
|
image = "https://media.giphy.com/media/Uq9bGjGKg08M0/giphy.gif";
|
2024-06-11 13:17:37 +02:00
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
{ urlEncode = true; }
|
|
|
|
];
|
2024-04-12 20:56:42 +02:00
|
|
|
|
|
|
|
};
|
2023-12-22 20:28:52 +01:00
|
|
|
};
|
|
|
|
};
|
2024-04-12 20:56:42 +02:00
|
|
|
})
|
|
|
|
];
|
2023-12-22 20:28:52 +01:00
|
|
|
}
|