From 87ac8351489e6deca57c7b908585f46b6d8bf0fc Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 7 Dec 2021 19:51:25 +0100 Subject: [PATCH] VEGAS/api: init --- hosts/VEGAS/services/api/default.nix | 38 ++++++++++++++++++++++++++++ hosts/VEGAS/system.nix | 1 + 2 files changed, 39 insertions(+) create mode 100644 hosts/VEGAS/services/api/default.nix diff --git a/hosts/VEGAS/services/api/default.nix b/hosts/VEGAS/services/api/default.nix new file mode 100644 index 0000000..3e3a1b8 --- /dev/null +++ b/hosts/VEGAS/services/api/default.nix @@ -0,0 +1,38 @@ +{ config, lib, tools, ... }: +let + inherit (tools.meta) domain; + apiAddr = "api.${domain}"; + proxyTarget = "http://127.0.0.1:${config.portsStr.api}"; + proxy = tools.nginx.vhosts.proxy proxyTarget; +in +{ + reservePortsFor = [ "api" ]; + + services.n8n = { + enable = true; + settings = { + port = config.ports.api; + }; + }; + + systemd.services.n8n.environment = { + N8N_LISTEN_ADDRESS = "127.0.0.1"; + N8N_ENDPOINT_WEBHOOK = "api"; + N8N_ENDPOINT_WEBHOOK_TEST = "test"; + WEBHOOK_URL = "https://${apiAddr}"; + }; + + services.nginx.virtualHosts."${apiAddr}" = lib.recursiveUpdate proxy { + locations."/api" = { + proxyPass = proxyTarget; + extraConfig = "auth_request off;"; + }; + locations."/test" = { + proxyPass = proxyTarget; + extraConfig = "auth_request off;"; + }; + }; + + + services.oauth2_proxy.nginx.virtualHosts = [ apiAddr ]; +} diff --git a/hosts/VEGAS/system.nix b/hosts/VEGAS/system.nix index c0e0698..0a0d075 100644 --- a/hosts/VEGAS/system.nix +++ b/hosts/VEGAS/system.nix @@ -15,6 +15,7 @@ inputs.agenix.nixosModules.age # Services + ./services/api ./services/backbone-routing ./services/bitwarden ./services/cdn-shield