1. Caddy version (caddy version
):
v2.4.6
2. How I run Caddy:
a. System environment:
Using docker desktop for windows 4.7.0
b. Command:
Currently using docker commands, will switch to docker compose after I am satisfied with my understanding of the workings:
docker run -d -p 443:443 -p 80:80 -p 8080:8080 --name website -v ${PWD}/Caddyfile:/etc/caddy/Caddyfile:ro -v caddy_data:/data caddy-duckdns
The image caddy-duckdns is one I created using a dockerfile while doing a crash-course docker (shown below), essentially it is the base image with duckdns module:
FROM caddy:2-builder AS builder
RUN xcaddy build \
--with github.com/caddy-dns/duckdns
FROM caddy:2
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
c. Service/unit/compose file:
d. My complete Caddyfile or JSON config:
http://my-domain.duckdns.org {
respond "Hello world"
}
http://duck.my-domain.duckdns.org {
respond "It's a duck world!"
}
3. The problem I’m having / What I tried:
I am pretty new to the whole world of servers / websites / certificates and still a little inexperienced in docker, so perhaps WHY this is not working is rather obvious, in that case a ELI5 explanation is perhaps more appropriate.
(While writing this help request I actually got a little further than I was initially, guess the template is helping )
my-domain.duckdns.org points to an internal IP adress. Now I am trying to understand how subdomains can be redirected so I can use these subdomains to point to different containers on my home server.
I started out with a simple caddyfile:
:80 {
respond "Hello world"
}
:8080 {
respond "Goodbye world"
}
Opened in browser, got the right responses when typing in the IP address with the given ports. Sweet! In the future I will of course be using reverse_proxy but for testing this was fine.
I also verified I got the hello world response when using my-domain.duckdns.org in the browser.
Next I tried the caddyfile listed above, but then my browser returns a ERR_CONNECTION_CLOSED response. I tried it without the HTTP:// part but then I get the error ERR_SSL_PROTOCOL_ERROR. Now this one I think I understand, by default caddy uses HTTPS and I havent got a certificate and this server is not reachable from the web so a secured connection cannot be established. (Correct?)
I have also tried this caddyfile, which uses (a slightly magic for me) DNS challenge to get a certificate:
my-domain.duckdns.org {
tls {
dns duckdns <duckdns token>
}
respond "Hello world"
}
duck.my-domain.duckdns.org {
tls {
dns duckdns <duckdns token>
}
respond "It's a DUCK world"
}
And this works as expected!
Now, when writing this, I also tested the http version listed above with curl (as recommended by the template), which IS getting the correct responses!
So I guess my real question boils down to: why is my browser getting the ERR_CONNECTION_CLOSED response when trying to navigate to http://my-domain.duckdns.org when using the http version of my caddyfile?
4. Error messages and/or full log output:
5. What I already tried:
6. Links to relevant resources:
PS: I am not seeing the preview in chrome or edge, any help on that as well?