2023-08-31 01:55:45 +03:00
|
|
|
{ config, lib, depot, ... }:
|
2021-12-07 20:51:25 +02:00
|
|
|
let
|
2023-08-31 01:55:45 +03:00
|
|
|
inherit (depot.lib.meta) domain;
|
2021-12-07 20:51:25 +02:00
|
|
|
apiAddr = "api.${domain}";
|
2022-06-18 03:44:51 +03:00
|
|
|
proxyTarget = config.links.api.url;
|
2023-08-31 01:55:45 +03:00
|
|
|
proxy = depot.lib.nginx.vhosts.proxy proxyTarget;
|
2021-12-07 20:51:25 +02:00
|
|
|
in
|
|
|
|
{
|
2022-05-30 23:33:12 +03:00
|
|
|
# n8n uses "Sustainable Use License"
|
|
|
|
nixpkgs.config.allowUnfree = true;
|
|
|
|
|
2022-06-18 03:44:51 +03:00
|
|
|
links.api.protocol = "http";
|
2021-12-07 20:51:25 +02:00
|
|
|
|
|
|
|
services.n8n = {
|
|
|
|
enable = true;
|
2023-12-02 20:27:36 +02:00
|
|
|
webhookUrl = "https://${apiAddr}";
|
2021-12-07 20:51:25 +02:00
|
|
|
settings = {
|
2022-06-18 03:44:51 +03:00
|
|
|
inherit (config.links.api) port;
|
2021-12-07 20:51:25 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.n8n.environment = {
|
|
|
|
N8N_LISTEN_ADDRESS = "127.0.0.1";
|
|
|
|
N8N_ENDPOINT_WEBHOOK = "api";
|
|
|
|
N8N_ENDPOINT_WEBHOOK_TEST = "test";
|
|
|
|
};
|
|
|
|
|
|
|
|
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 ];
|
|
|
|
}
|