From 3907b9a1bfaa85c56fc488f944c41db5628c8c7f Mon Sep 17 00:00:00 2001 From: Wilfried OLLIVIER Date: Tue, 19 May 2020 21:27:29 +0200 Subject: [PATCH] Update to caddy2 --- meta/main.yml | 2 +- templates/http.caddy.j2 | 32 ++++++++++++++------------------ 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/meta/main.yml b/meta/main.yml index 20f4796..847708d 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,6 +1,6 @@ galaxy_info: author: Wilfried OLLIVIER - description: Push caddy config file and sync code + description: Push caddy (2) config file and sync code company: none license: WTFPL diff --git a/templates/http.caddy.j2 b/templates/http.caddy.j2 index 58161de..5b51b69 100644 --- a/templates/http.caddy.j2 +++ b/templates/http.caddy.j2 @@ -12,27 +12,23 @@ X-Frame-Options "DENY" } - log {{ caddy_logs }}/{{ vhost_name }}/access.log { - rotate_size 100 - rotate_age 30 - rotate_keep 10 + log { + output file {{ caddy_logs }}/{{ vhost_name }}/vhost.log } - errors {{ caddy_logs }}/{{ vhost_name }}/errors.log { - rotate_size 100 - rotate_age 30 - rotate_keep 10 + root * {{ caddy_www }}/{{ vhost_name }} + file_server + encode zstd gzip + + {% if custom_errors %} + handle_errors { + @404 { + expression {http.error.status_code} == 404 + } + rewrite @404 /404.html + file_server } - - root {{ caddy_www }}/{{ vhost_name }} - - gzip - -{% if custom_errors %} - errors { - 404 404.html # Not Found - } -{% endif %} + {% endif %} }