aboutsummaryrefslogtreecommitdiff
path: root/hosts/enode/caddy.nix
diff options
context:
space:
mode:
authorIsabella Bastaja <isabella@sorre.xyz>2026-08-30 17:16:32 +0200
committerIsabella Bastaja <isabella@sorre.xyz>2026-08-30 18:36:58 +0200
commitdc25aed7041c51f1780c0a9f311e6eb90fd42217 (patch)
treea36eaf1f44c085e29584fac8282335465c95ea54 /hosts/enode/caddy.nix
parent83bf1be6c86f6d8ef506ba9d6046424f4ce18b69 (diff)
WIP: init enode host
Diffstat (limited to 'hosts/enode/caddy.nix')
-rw-r--r--hosts/enode/caddy.nix45
1 files changed, 45 insertions, 0 deletions
diff --git a/hosts/enode/caddy.nix b/hosts/enode/caddy.nix
new file mode 100644
index 0000000..bc3b745
--- /dev/null
+++ b/hosts/enode/caddy.nix
@@ -0,0 +1,45 @@
+{ config, ... }:
+let
+ headscale = {
+ domain = config.services.headscale.address;
+ port = config.services.headscale.port;
+ };
+
+ simpleProxies = {
+ "sorre.xyz" = "tower.sorre.internal:7291";
+ "git.sorre.xyz" = "tower.sorre.internal:8721";
+ "idm.sorre.xyz" = "tower.sorre.internal:8443";
+ };
+
+ simpleProxyVirtualHosts = builtins.mapAttrs (domain: upstream: {
+ extraConfig = ''
+ reverse_proxy ${upstream} {
+ headers_up True-Client-IP {remote_host}
+ header_up X-Real-IP {remote_host}
+ }
+ '';
+ }) simpleProxies;
+in
+{
+ services.caddy = {
+ enable = true;
+ virtualHosts = {
+ "http://headscale.sorre.xyz".extraConfig = ''
+ handle /generate_204 {
+ respond 204
+ }
+
+ handle * {
+ redir https://{host}{uri}
+ }
+ '';
+ "headscale.sorre.xyz".extraConfig = ''
+ reverse_proxy ${headscale.domain}:${toString headscale.port} {
+ headers_up True-Client-IP {remote_host}
+ header_up X-Real-IP {remote_host}
+ }
+ '';
+ }
+ // simpleProxyVirtualHosts;
+ };
+}