diff --git a/seb4itik/byow/roles/caddy/tasks/caddy_config.yml b/seb4itik/byow/roles/caddy/tasks/caddy_config.yml index 3bcc879..16592ad 100644 --- a/seb4itik/byow/roles/caddy/tasks/caddy_config.yml +++ b/seb4itik/byow/roles/caddy/tasks/caddy_config.yml @@ -5,6 +5,7 @@ - name: Configure Caddy Coraza CRS when: "caddy_coraza" block: + - name: Create sites config directories loop: "{{ caddy_sites }}" ansible.builtin.file: @@ -12,6 +13,7 @@ state: "directory" group: "{{ caddy_system_group }}" mode: "0750" + - name: Generate sites coraza.conf config file loop: "{{ caddy_sites }}" loop_control: @@ -23,6 +25,7 @@ mode: "0640" notify: - "Restart Caddy" + - name: Generate sites crs-setup config file loop: "{{ caddy_sites }}" loop_control: @@ -34,6 +37,7 @@ mode: "0640" notify: - "Restart Caddy" + - name: Generate sites exclusions before request file loop: "{{ caddy_sites }}" loop_control: @@ -45,6 +49,7 @@ mode: "0640" notify: - "Restart Caddy" + - name: Generate sites exclusions after response file loop: "{{ caddy_sites }}" loop_control: @@ -57,6 +62,7 @@ notify: - "Restart Caddy" +# FIXME: Should per site - name: Copy bot barrier template when: "caddy_bot_barrier" ansible.builtin.copy: diff --git a/seb4itik/byow/roles/caddy/templates/Caddyfile b/seb4itik/byow/roles/caddy/templates/Caddyfile index b7ee38d..e47db00 100644 --- a/seb4itik/byow/roles/caddy/templates/Caddyfile +++ b/seb4itik/byow/roles/caddy/templates/Caddyfile @@ -16,8 +16,8 @@ order coraza_waf first {% endif %} -# See: https://github.com/pteich/caddy-tlsconsul {% if caddy_consul %} + # See: https://github.com/pteich/caddy-tlsconsul storage consul { address "{{ caddy_consul_server }}" token "{{ caddy_out_consul_token.token.SecretID | mandatory }}" @@ -30,8 +30,8 @@ } {% endif %} -# See: https://github.com/zhangjiayin/caddy-geoip2 {% if caddy_geoip %} + # See: https://github.com/zhangjiayin/caddy-geoip2 geoip2 { accountId "{{ caddy_geoip_account_id | mandatory }}" licenseKey "{{ caddy_geoip_license_key | mandatory }}" @@ -47,8 +47,8 @@ email "{{ caddy_email }}" {% endif %} -# See: https://github.com/hslatman/caddy-crowdsec-bouncer {% if caddy_crowdsec %} + # See: https://github.com/hslatman/caddy-crowdsec-bouncer crowdsec { api_key {{ caddy_crowdsec_api_key | mandatory }} api_url {{ caddy_crowdsec_api_url }} @@ -233,8 +233,8 @@ {% endfor %} } -# See: https://github.com/mholt/caddy-ratelimit {% if caddy_ratelimit and site.rate_limit | default(caddy_sites_defaults.rate_limit) %} + # See: https://github.com/mholt/caddy-ratelimit rate_limit @not_whitelisted { {% if caddy_consul %} distributed @@ -292,8 +292,8 @@ import cors-deny {% endif %} -# See: https://github.com/steffenbusch/caddy-bot-barrier {% if caddy_bot_barrier and site.bot_barrier | default(caddy_sites_defaults.bot_barrier) %} + # See: https://github.com/steffenbusch/caddy-bot-barrier bot_barrier @not_whitelisted { secret {{ site.bot_barrier_secret | default(caddy_sites_defaults.bot_barrier_secret) | mandatory }} complexity {{ site.bot_barrier_complexity | default(caddy_sites_defaults.bot_barrier_complexity) }}