about summary refs log tree commit diff
path: root/bundles/lhost/files
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2025-09-07 17:32:13 +0200
committerRobert Günzler <r@gnzler.io>2025-09-07 17:42:42 +0200
commit38be6c13f76e893cf47636257071b440dec0c5b2 (patch)
treef7ded3235a7e3362cbd1ed3d91523968fe0faf90 /bundles/lhost/files
initial commit
Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to 'bundles/lhost/files')
-rw-r--r--bundles/lhost/files/Caddyfile45
-rwxr-xr-xbundles/lhost/files/lhost-prune20
-rw-r--r--bundles/lhost/files/lhost.conf1
-rw-r--r--bundles/lhost/files/traefik.yaml18
4 files changed, 84 insertions, 0 deletions
diff --git a/bundles/lhost/files/Caddyfile b/bundles/lhost/files/Caddyfile
new file mode 100644
index 0000000..497ef30
--- /dev/null
+++ b/bundles/lhost/files/Caddyfile
@@ -0,0 +1,45 @@
+# vim: noet ts=2 sw=2
+{
+	admin off
+	auto_https off
+	http_port {$CADDY_HTTP_PORT:1414}
+}
+
+http:// {
+	encode zstd gzip
+
+	handle /healthz {
+		respond OK 200
+	}
+
+	handle {
+		root .
+		file_server {
+			hide Caddyfile
+			hide .keep
+		}
+	}
+
+	# catch all
+	respond 404
+
+	log {
+		format filter {
+			wrap console {
+				time_format wall_milli
+				level_format color
+			}
+			fields {
+				common_log delete
+				request>headers>Accept-Encoding delete
+				request>headers>Accept-Language delete
+				request>headers>Connection delete
+				request>headers>Authorization delete
+				request>remote_addr ip_mask {
+					ipv4 24
+					ipv6 32
+				}
+			}
+		}
+	}
+}
diff --git a/bundles/lhost/files/lhost-prune b/bundles/lhost/files/lhost-prune
new file mode 100755
index 0000000..8788941
--- /dev/null
+++ b/bundles/lhost/files/lhost-prune
@@ -0,0 +1,20 @@
+#!/bin/sh
+set -eu
+
+main() {
+	local dryrun=$(test -n "${DRYRUN:-}" && printf echo)
+	local root=${ROOT:-/var/www/lhost}
+	local maxage=${MAXAGE:-30}
+
+	find ${root} \
+		-type f \
+		-mtime ${maxage} \
+		-not \( \
+		-name 'Caddyfile' -or \
+		-name '.keep' -or \
+		-name "$(cat ${root}/.keep)" \
+		\) \
+		-exec ${dryrun} rm -rv {} +
+}
+
+main >/dev/null 2>&1
diff --git a/bundles/lhost/files/lhost.conf b/bundles/lhost/files/lhost.conf
new file mode 100644
index 0000000..fbf2dc6
--- /dev/null
+++ b/bundles/lhost/files/lhost.conf
@@ -0,0 +1 @@
+www_port=${node.metadata.get("www/lhost/port")}
diff --git a/bundles/lhost/files/traefik.yaml b/bundles/lhost/files/traefik.yaml
new file mode 100644
index 0000000..d1722a0
--- /dev/null
+++ b/bundles/lhost/files/traefik.yaml
@@ -0,0 +1,18 @@
+http:
+  services:
+    lhost:
+      loadBalancer:
+        servers:
+          - url: http://${node.metadata.get("container_gateway", "10.89.0.1")}:${node.metadata.get("www/lhost/port")}
+
+  routers:
+    lhost:
+      rule: Host(`l.gzr.im`)
+      entryPoints:
+        - http
+        - https
+      service: lhost
+      middlewares:
+        - tls-redirect@file
+      tls:
+        certResolver: le