1. Caddy version (caddy version
):
2.1.1
2. How I run Caddy:
a. System environment:
Linux - Manjaro KDE
Docker 19.03
b. Command:
docker run --rm -it \
--name caddytest \
-p 80:80 -p 443:443 \
-v $PWD/public:/usr/share/caddy/ \
-v $PWD/caddy/data:/data \
-v $PWD/caddy/Caddyfile:/etc/caddy/Caddyfile \
-v $PWD/caddy/tls:/tls caddy
c. Service/unit/compose file:
N/A
d. My complete Caddyfile or JSON config:
http://pugs.localhost https://pugs.localhost {
#tls internal
tls /tls/pugs.localhost.pem /tls/pugs.localhost-key.pem
root * /usr/share/caddy
file_server
}
3. The problem I’m having:
Support HTTP and HTTPS without redirect, but providing local cert for TLS when using HTTPS. Fails.
4. Error messages and/or full log output:
Not necessary for localhost
site address as Caddy would otherwise enable this implicitly for HTTPS, When explicit produces same problem:
tls internal
:
run: adapting config using caddyfile: hostname appears in more than one automation policy, making certificate management ambiguous: pugs.localhost
Supplying my own certificate with tls cert.pem key.pem
:
run: adapting config using caddyfile: server listening on [:80] is HTTP, but attempts to configure TLS connection policies
5. What I already tried:
- Duplicating the inner config with the HTTPS block version having the tls line.
- Creating a snippet for the shared block content and using
import snippet_name
in each block.
Both of those work, just curious if it can all be managed in a single block instead of one for each protocol + snippet.
Also tried using handle protocol https {}
to wrap the tls
directive in conditionally, but this failed with error:
run: adapting config using caddyfile: parsing caddyfile tokens for 'handle': directive 'tls' is not ordered, so it cannot be used here