From 84db337fea8d9ff44d59046efb3f06808bc609a6 Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Sat, 29 Mar 2025 19:33:02 +0300 Subject: [PATCH] roles/caddy: smarter setting of document root --- roles/caddy/templates/etc/caddy/conf.d/vhost.j2 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/roles/caddy/templates/etc/caddy/conf.d/vhost.j2 b/roles/caddy/templates/etc/caddy/conf.d/vhost.j2 index 810ade9..00bcb5a 100644 --- a/roles/caddy/templates/etc/caddy/conf.d/vhost.j2 +++ b/roles/caddy/templates/etc/caddy/conf.d/vhost.j2 @@ -8,6 +8,12 @@ {% set needs_php = item.needs_php | default(false) %} {% set has_gitea = item.has_gitea | default(false) %} {% set static_site = item.static_site | default(false) %} +{# Allow sites to override the document root #} +{% if item.document_root is defined %} +{% set document_root = item.document_root %} +{% else %} +{% set document_root = (caddy_root_prefix, domain_name) | ansible.builtin.path_join %} +{% endif %} {% if domain_aliases %} {# domain_aliases is a string, so we split on space #} @@ -22,7 +28,7 @@ {% if has_gitea %} reverse_proxy :3000 {% elif static_site -%} - root * {{ item.document_root }} + root * {{ document_root }} encode zstd gzip