{%- if parameter_dict['domain']  -%}

{{ parameter_dict['domain'] }} {

tls {{ custom_cert_dict['cert-file'] }} {{ custom_cert_dict['key-file'] }} {

  ca {{ca_custom_frontend_dict['rendered']}}

}

log {{caddy_configuration_dict['access_log']}}

errors {{caddy_configuration_dict['error_log']}}

root {{ directory_dict['public_html'] }}

{% if parameter_dict['enable-basic-auth'] == 'true'  -%}
basicauth / {{ parameter_dict['username'] }} {{parameter_dict['password']}}

{%- endif %}

{% if parameter_dict['proxy'] == 'true'  -%}

  {% if parameter_dict['type'] == 'zope'  -%}

  proxy / {{parameter_dict['url']}}/VirtualHostBase/https/{{ parameter_dict['domain'] }}/VirtualHostRoot/ {

  insecure_skip_verify

  }

  {% else %}
    proxy / 	{{parameter_dict['url']}}
  {%- endif %}

  {%- endif %}

  bind {{caddy_configuration_dict['ipv6']}}

}

{%- endif %}

[{{caddy_configuration_dict['ipv6']}}]:{{parameter_dict['port']}} {

  tls {{ custom_cert_dict['cert-file'] }} {{ custom_cert_dict['key-file'] }} {

    ca {{ certificate_authority_dict['ca-cert-file'] }}

  }

  log {{caddy_configuration_dict['access_log']}}
  
  errors {{caddy_configuration_dict['error_log']}}

  root {{ directory_dict['public_html'] }}

  {% if parameter_dict['enable-basic-auth'] == 'true'  -%}
  basicauth / {{ parameter_dict['username'] }} {{parameter_dict['password']}}
  {%- endif %}
  
  {% if parameter_dict['proxy'] == 'true'  -%}

  {% if parameter_dict['type'] == 'zope'  -%}

  proxy / {{parameter_dict['url']}}/VirtualHostBase/https/[{{caddy_configuration_dict['ipv6']}}]:{{parameter_dict['port']}}/VirtualHostRoot/ {

  insecure_skip_verify

  }

  {% else %}
    proxy / 	{{parameter_dict['url']}}
  {%- endif %}

  {%- endif %}
  bind {{caddy_configuration_dict['ipv6']}}
}

[{{caddy_configuration_dict['local_ip']}}]:{{parameter_dict['port']}} {

  log {{caddy_configuration_dict['access_log']}}
  
  errors {{caddy_configuration_dict['error_log']}}

  root {{ directory_dict['public_html'] }}

  {% if parameter_dict['enable-basic-auth'] == 'true'  -%}
  basicauth / {{ parameter_dict['username'] }} {{parameter_dict['password']}}
  {%- endif %}
  
  bind {{caddy_configuration_dict['local_ip']}}

}