aboutsummaryrefslogtreecommitdiff
path: root/hosts
diff options
context:
space:
mode:
Diffstat (limited to 'hosts')
-rw-r--r--hosts/sagittarius/web/default.nix2
-rw-r--r--hosts/sagittarius/web/matrix.nix117
-rw-r--r--hosts/sagittarius/web/observability.nix183
3 files changed, 0 insertions, 302 deletions
diff --git a/hosts/sagittarius/web/default.nix b/hosts/sagittarius/web/default.nix
index c95806e..2ccf36b 100644
--- a/hosts/sagittarius/web/default.nix
+++ b/hosts/sagittarius/web/default.nix
@@ -2,11 +2,9 @@
{
imports = [
./blog.nix
- ./matrix.nix
./mediadb.nix
./git.nix
./static.nix
./navidrome.nix
- # ./observability.nix
];
}
diff --git a/hosts/sagittarius/web/matrix.nix b/hosts/sagittarius/web/matrix.nix
deleted file mode 100644
index c971ddc..0000000
--- a/hosts/sagittarius/web/matrix.nix
+++ /dev/null
@@ -1,117 +0,0 @@
-{ pkgs, config, ... }:
-let
- server_name = "sorre.xyz";
- matrix_hostname = "matrix.${server_name}";
- #admin_email = "gloss_unranked088@simplelogin.com";
-
- # Build a dervation that stores the content of `${server_name}/.well-known/matrix/server`
- well_known_server = pkgs.writeText "well-known-matrix-server" ''
- {
- "m.server": "${matrix_hostname}"
- }
- '';
-
- # Build a dervation that stores the content of `${server_name}/.well-known/matrix/client`
- well_known_client = pkgs.writeText "well-known-matrix-client" ''
- {
- "m.homeserver": {
- "base_url": "https://${matrix_hostname}"
- }
- }
- '';
-in
-{
- imports = [ ./acme.nix ];
-
- networking.firewall.allowedTCPPorts = [
- 80
- 443
- 8448
- ];
- networking.firewall.allowedUDPPorts = [
- 80
- 443
- 8448
- ];
-
- services.matrix-conduit = {
- enable = true;
- settings.global.server_name = server_name;
- settings.global.allow_registration = false;
- };
-
- services.nginx = {
- enable = true;
- recommendedProxySettings = true;
-
- virtualHosts."${matrix_hostname}" = {
- enableACME = true;
- forceSSL = true;
-
- listen = [
- {
- addr = "0.0.0.0";
- port = 443;
- ssl = true;
- }
- {
- addr = "[::]";
- port = 443;
- ssl = true;
- }
- {
- addr = "0.0.0.0";
- port = 8448;
- ssl = true;
- }
- {
- addr = "[::]";
- port = 8448;
- ssl = true;
- }
- ];
- locations."/_matrix/" = {
- proxyPass = "http://backend_conduit$request_uri";
- proxyWebsockets = true;
- extraConfig = ''
- proxy_set_header Host $host;
- proxy_buffering off;
- '';
- };
- extraConfig = ''
- merge_slashes off;
- '';
- };
-
- virtualHosts."${server_name}" = {
- enableACME = true;
- forceSSL = true;
-
- locations = {
- "=/.well-known/matrix/server" = {
- alias = "${well_known_server}";
- extraConfig = ''
- # Set the header since by default NGINX thinks it's just bytes
- default_type application/json;
- '';
- };
- "=/.well-known/matrix/client" = {
- # Use the contents of the derivation built previously
- alias = "${well_known_client}";
-
- extraConfig = ''
- # Set the header since by default NGINX thinks it's just bytes
- default_type application/json;
-
- # https://matrix.org/docs/spec/client_server/r0.4.0#web-browser-clients
- add_header Access-Control-Allow-Origin "*";
- '';
- };
- };
- };
-
- upstreams."backend_conduit".servers = {
- "[::1]:${toString config.services.matrix-conduit.settings.global.port}" = { };
- };
- };
-}
diff --git a/hosts/sagittarius/web/observability.nix b/hosts/sagittarius/web/observability.nix
deleted file mode 100644
index f622822..0000000
--- a/hosts/sagittarius/web/observability.nix
+++ /dev/null
@@ -1,183 +0,0 @@
-{ config, ... }:
-let
- otel-prometheus-exporter-port = 4316;
-
- grafana-cfg = config.services.grafana;
- prometheus-cfg = config.services.prometheus;
- # clickhouse-cfg = config.services.clickhouse;
-in
-{
- services.opentelemetry-collector = {
- enable = true;
- settings = {
- receivers = {
- otlp = {
- protocols = {
- grpc.endpoint = "localhost:4317";
- http.endpoint = "localhost:4318";
- };
- };
- hostmetrics.scrapers = {
- cpu = { };
- disk = { };
- filesystem = { };
- load = { };
- memory = { };
- network = { };
- process = { };
- processes = { };
- paging = { };
- };
- };
- processors = {
- memory_limiter = {
- check_interval = "5s";
- limit_mib = 2500;
- spike_limit_mib = 500;
- };
- batch = {
- timeout = "10s";
- send_batch_size = 100;
- };
- };
- exporters = {
- debug = {
- verbosity = "detailed";
- };
- prometheus = {
- endpoint = "localhost:${toString otel-prometheus-exporter-port}";
- send_timestamps = true;
- enable_open_metrics = true;
- };
- # clickhouse = {
- # endpoint = "tcp://localhost:${toString clickhouse-cfg.serverConfig.tcp_port}";
- # database = "otel";
- # username = "otel";
- # password = "";
- # async_insert = true;
- # ttl = "72h";
- # compress = "lz4";
- # create_schema = true;
- # logs_table_name = "otel_logs";
- # traces_table_name = "otel_traces";
- # timeout = "5s";
- # metrics_tables = {
- # gauge.name = "otel_metrics_gauge";
- # sum.name = "otel_metrics_sum";
- # summary.name = "otel_metrics_summary";
- # histogram.name = "otel_metrics_histogram";
- # exponential_histogram.name = "otel_metrics_exp_histogram";
- # };
- # retry_on_failure = {
- # enabled = true;
- # initial_interval = "5s";
- # max_interval = "30s";
- # max_elapsed_time = "300s";
- # };
- # };
- };
- service = {
- extensions = [ ];
- pipelines = {
- traces = {
- receivers = [ "otlp" ];
- exporters = [
- "debug"
- # "clickhouse"
- ];
- };
- metrics = {
- receivers = [
- "otlp"
- "hostmetrics"
- ];
- exporters = [
- "debug"
- "prometheus"
- # "clickhouse"
- ];
- };
- logs = {
- receivers = [ "otlp" ];
- exporters = [
- "debug"
- # "clickhouse"
- ];
- };
- };
- };
- };
- };
-
- services.prometheus = {
- enable = true;
- globalConfig = {
- scrape_timeout = "10s";
- scrape_interval = "1m";
- };
- scrapeConfigs = [
- {
- job_name = "otel";
- scrape_interval = "5s";
- static_configs = [
- {
- targets = [ "localhost:${toString otel-prometheus-exporter-port}" ];
- }
- ];
- }
- ];
- };
-
- services.grafana = {
- enable = true;
- settings = {
- server = {
- http_addr = "127.0.0.1";
- http_port = 9001;
- domain = "grafana.sorre.xyz";
- root_url = "https://grafana.sorre.xyz/";
- serve_from_sub_path = true;
- };
- };
- provision = {
- enable = true;
- datasources.settings = {
- prune = true;
- datasources = [
- {
- type = "prometheus";
- name = "prometheus";
- url = "http://localhost:${toString prometheus-cfg.port}";
- }
- ];
- };
- };
- };
-
- # services.clickhouse = {
- # enable = true;
- # # NOTE: manually created the "otel" user and database
- # serverConfig = {
- # http_port = 8123;
- # tcp_port = 9000;
- # };
- # };
-
- services.nginx.virtualHosts."grafana.sorre.xyz" = {
- forceSSL = true;
- enableACME = true;
- locations."/" =
- let
- proxyPass =
- "http://"
- + (toString grafana-cfg.settings.server.http_addr)
- + ":"
- + (toString grafana-cfg.settings.server.http_port);
- in
- {
- inherit proxyPass;
- proxyWebsockets = true;
- recommendedProxySettings = true;
- };
- };
-}