diff options
Diffstat (limited to 'bundles/lhost')
| -rw-r--r-- | bundles/lhost/files/Caddyfile | 45 | ||||
| -rwxr-xr-x | bundles/lhost/files/lhost-prune | 20 | ||||
| -rw-r--r-- | bundles/lhost/files/lhost.conf | 1 | ||||
| -rw-r--r-- | bundles/lhost/files/traefik.yaml | 18 | ||||
| -rw-r--r-- | bundles/lhost/items.py | 24 | ||||
| -rw-r--r-- | bundles/lhost/metadata.py | 5 |
6 files changed, 113 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 diff --git a/bundles/lhost/items.py b/bundles/lhost/items.py new file mode 100644 index 0000000..ac2e428 --- /dev/null +++ b/bundles/lhost/items.py @@ -0,0 +1,24 @@ +directories = { + "/var/www/lhost": { + "mode": "0775", + "group": "www-data", + "owner": "webdeploy", + }, +} + +files = { + "/var/www/lhost/Caddyfile": {}, + "/etc/traefik/lhost.yaml": { + "content_type": "mako", + "source": "traefik.yaml", + "needs": { + "bundle:traefik", + }, + }, + "/etc/s6-rc/lhost.conf": { + "content_type": "mako", + }, + "/etc/periodic/weekly/lhost-prune": { + "mode": "0755", + }, +} diff --git a/bundles/lhost/metadata.py b/bundles/lhost/metadata.py new file mode 100644 index 0000000..a0a86b6 --- /dev/null +++ b/bundles/lhost/metadata.py @@ -0,0 +1,5 @@ +defaults = { + "www": { + "lhost": {}, + }, +} |