www/caddy: template fix tls_server_name option (#3948)

* Update Caddyfile

It is allowed for these TLS Options to appear more freely inside the transport_http blocks without producing an invalid configuration.

For example, "tls_server_name" is not required to appear together with "tls"

* Update Caddy.xml

Ensure that when "NTLM" is chosen, TLS has to be enabled at the same time.
This commit is contained in:
Monviech
2024-05-06 16:05:10 +02:00
committed by GitHub
parent 10d0bc8e7c
commit b3a6eca348
2 changed files with 27 additions and 9 deletions
@@ -290,8 +290,24 @@
<MaximumValue>100</MaximumValue>
<ValidationMessage>Please enter a value between 1 to 100.</ValidationMessage>
</PassiveHealthFailDuration>
<HttpTls type="BooleanField"/>
<HttpNtlm type="BooleanField"/>
<HttpTls type="BooleanField">
<Constraints>
<check001>
<ValidationMessage>TLS and NTLM must be enabled at the same time.</ValidationMessage>
<type>DependConstraint</type>
<addFields>
<field1>HttpNtlm</field1>
</addFields>
</check001>
</Constraints>
</HttpTls>
<HttpNtlm type="BooleanField">
<Constraints>
<check001>
<reference>HttpNtlm.check001</reference>
</check001>
</Constraints>
</HttpNtlm>
<HttpTlsInsecureSkipVerify type="BooleanField"/>
<HttpTlsTrustedCaCerts type="CertificateField">
<Type>ca</Type>
@@ -523,34 +523,36 @@
{% if handle.PassiveHealthFailDuration|default("") %}
fail_duration {{ handle.PassiveHealthFailDuration }}s
{% endif %}
{% if handle.HttpTls|default("0") == "1" or handle.HttpTlsInsecureSkipVerify|default("0") == "1" %}
{% if handle.HttpTls|default("0") == "1" or handle.HttpTlsInsecureSkipVerify|default("0") == "1" or handle.HttpTlsTrustedCaCerts|default("") != "" or handle.HttpTlsServerName|default("") != "" %}
{% if handle.HttpNtlm|default("0") == "1" %}
transport http_ntlm {
{% if handle.HttpTls|default("0") == "1" %}
tls
{% endif %}
{% if handle.HttpTlsInsecureSkipVerify|default("0") == "1" %}
tls_insecure_skip_verify
{% else %}
tls
{% endif %}
{% if handle.HttpTlsTrustedCaCerts %}
tls_trusted_ca_certs /var/db/caddy/data/caddy/certificates/temp/{{ handle.HttpTlsTrustedCaCerts }}.pem
{% endif %}
{% if handle.HttpTlsServerName %}
tls_server_name {{ handle.HttpTlsServerName }}
{% endif %}
{% endif %}
}
{% else %}
transport http {
{% if handle.HttpTls|default("0") == "1" %}
tls
{% endif %}
{% if handle.HttpTlsInsecureSkipVerify|default("0") == "1" %}
tls_insecure_skip_verify
{% else %}
tls
{% endif %}
{% if handle.HttpTlsTrustedCaCerts %}
tls_trusted_ca_certs /var/db/caddy/data/caddy/certificates/temp/{{ handle.HttpTlsTrustedCaCerts }}.pem
{% endif %}
{% if handle.HttpTlsServerName %}
tls_server_name {{ handle.HttpTlsServerName }}
{% endif %}
{% endif %}
}
{% endif %}
{% endif %}