1. Caddy version: v2.5.0 h1:eRHzZ4l3X6Ag3kUt8nj5IxATprhqKq/wToP7OHlXWA0=
2. How I installed, and run Caddy:
docker-compose
a. System environment: Debian
Docker version 20.10.5+dfsg1, build 55c4c88
docker-compose version 1.25.0
Linux version: 5.10.0-17-amd64
b. Command:
docker-compose up caddy
c. Service/unit/compose file:
caddy:
image: caddy:2.5.0-alpine
container_name: caddy
restart: always
ports:
- 80:80
- 443:443
- 2019:2019
volumes:
- ./caddy-data:/data
- ./Caddyfile:/etc/caddy/Caddyfile
- /home/<user>/web:/var/www
d. My complete Caddy config:
icheered.nl www.icheered.nl {
root * /var/www/ICheeredWebsite
file_server
}
3. The problem I’m having:
https://icheered.nl works fine
http://icheered.nl is not loading
It seems that the HTTP request is not being redirected to the HTTPS version. It took a very long time for me to discover this issue because I only checked “icheered.nl” which automatically redirected to the https version, and the chrome browser on my phone redirects manually enetered http links to the https version automatically before making the request.
4. Error messages and/or full log output:
These are the logs from the docker container that is running caddy.
{"level":"info","ts":1675590145.8682392,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":"caddyfile"}
{"level":"warn","ts":1675590145.868944,"msg":"Caddyfile input is not formatted; run the 'caddy fmt' command to fix inconsistencies","adapter":"caddyfile","file":"/etc/caddy/Caddyfile","line":2}
{"level":"info","ts":1675590145.869519,"logger":"admin","msg":"admin endpoint started","address":"tcp/localhost:2019","enforce_origin":false,"origins":["//127.0.0.1:2019","//localhost:2019","//[::1]:2019"]}
{"level":"info","ts":1675590145.8696437,"logger":"http","msg":"server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS","server_name":"srv0","https_port":443}
{"level":"info","ts":1675590145.8696597,"logger":"http","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"srv0"}
{"level":"info","ts":1675590145.869693,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc000438a80"}
{"level":"info","ts":1675590145.8699696,"logger":"http","msg":"enabling automatic TLS certificate management","domains":["icheered.nl","www.icheered.nl"]}
{"level":"info","ts":1675590145.869972,"logger":"tls","msg":"cleaning storage unit","description":"FileStorage:/data/caddy"}
{"level":"info","ts":1675590145.8711853,"msg":"autosaved config (load with --resume flag)","file":"/config/caddy/autosave.json"}
{"level":"info","ts":1675590145.8712063,"msg":"serving initial configuration"}
{"level":"info","ts":1675590145.8749053,"logger":"tls","msg":"finished cleaning storage units"}
5. What I already tried:
I tried the following additions to my Caddyfile:
# Force redirect http to https
http://icheered.nl {
redir https://icheered.nl{uri}
}
# Redirect everything from port 80 to https
*:80 {
redir https://{domain}{uri}
}
I checked my router’s port-forwarding and port 80 traffic is forwarded correctly to the server.
6. Links to relevant resources:
(The solution didn’t work for me)