diff --git a/roles/vega_caddy_server/defaults/main.yaml b/roles/vega_caddy_server/defaults/main.yaml index d6834a7..7e4f2ca 100644 --- a/roles/vega_caddy_server/defaults/main.yaml +++ b/roles/vega_caddy_server/defaults/main.yaml @@ -12,9 +12,11 @@ vega_caddy_server_with_data_node_api: false vega_caddy_server_with_block_explorer_ui: false vega_caddy_server_with_governance_ui: false vega_caddy_server_with_trading_ui: false +vega_caddy_server_with_stats: false vega_caddy_server_block_explorer_api_domains: [] vega_caddy_server_data_node_api_domains: [] vega_caddy_server_block_explorer_ui_domains: [] vega_caddy_server_governance_ui_domains: [] vega_caddy_server_trading_ui_domains: [] +vega_caddy_server_stats_domains: [] diff --git a/roles/vega_caddy_server/tasks/main.yaml b/roles/vega_caddy_server/tasks/main.yaml index 2234fb7..76df848 100644 --- a/roles/vega_caddy_server/tasks/main.yaml +++ b/roles/vega_caddy_server/tasks/main.yaml @@ -61,3 +61,13 @@ mode: "0644" when: vega_caddy_server_with_trading_ui and vega_caddy_server_trading_ui_domains | length > 0 notify: "Restart caddy" + +- name: Enable stats config + ansible.builtin.template: + src: "etc/caddy/sites/stats.caddy.j2" + dest: "/etc/caddy/sites/stats.caddy" + owner: "caddy" + group: "caddy" + mode: "0644" + when: vega_caddy_server_with_stats and vega_caddy_server_stats_domains | length > 0 + notify: "Restart caddy" diff --git a/roles/vega_caddy_server/templates/etc/caddy/sites/stats.caddy.j2 b/roles/vega_caddy_server/templates/etc/caddy/sites/stats.caddy.j2 new file mode 100644 index 0000000..f98c7b6 --- /dev/null +++ b/roles/vega_caddy_server/templates/etc/caddy/sites/stats.caddy.j2 @@ -0,0 +1,14 @@ +{{- vega_caddy_server_stats_domains | map('ansible.builtin.regex_replace', '$', ':443') | join(', ') }} { + root * /var/www/stats + encode gzip + + file_server { + hide .git + index index.html + } + + handle_errors { + rewrite * /index.html + file_server + } +}