1. The problem I’m having:
I’ve noticed that my domain doesn’t forward my website automatically to the https:// domain when I just input the domain without http at all. I expect that when I put in domain.org, it should automatically be sent to https://r.domain.org/. When I use curl -vL domain.org
the output is actually correct here’s a snippet showing it
* Trying X.X.X.X:80...
* Connected to r.domain.org (X.X.X.X) port 80 (#0)
> GET / HTTP/1.1
> Host: r.domain.org
> User-Agent: curl/8.0.1
> Accept: */*
>
< HTTP/1.1 308 Permanent Redirect
< Connection: close
< Location: https://r.domain.org/
< Server: Caddy
< Date: Mon, 18 Sep 2023 11:45:49 GMT
< Content-Length: 0
But on many browsers, if I put http first or if I put nothing first it doesn’t redirect properly.
2. Error messages and/or full log output:
I couldn’t figure out how to enable debug mode, or the logs. I used
log {
output file /home/user/Code/caddy_log_output.txt
}
inside the domain I was interested in, but it didn’t generate the file.
3. Caddy version:
v2.7.4
4. How I installed and ran Caddy:
I believe I installed in using snap
a. System environment:
I’ve been running it on Ubuntu 22.04.3 LTS
b. Command:
I normally just let systemd run it as a service.
c. Service/unit/compose file:
# caddy.service
#
# For using Caddy with a config file.
#
# Make sure the ExecStart and ExecReload commands are correct
# for your installation.
#
# See https://caddyserver.com/docs/install for instructions.
#
# WARNING: This service does not use the --resume flag, so if you
# use the API to make changes, they will be overwritten by the
# Caddyfile next time the service is restarted. If you intend to
# use Caddy's API to configure it, add the --resume flag to the
# `caddy run` command or use the caddy-api.service file instead.
[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target network-online.target
Requires=network-online.target
[Service]
Type=notify
ExecStart=/usr/bin/caddy run --config /home/user/Code/Caddyfile
ExecReload=/usr/bin/caddy reload --config /home/user/Code/Caddyfile --force
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target
d. My complete Caddy config:
n.domain.org {
reverse_proxy :11000
}
j.domain.org {
reverse_proxy :8096
}
o.domain.org {
reverse_proxy :5000
}
r.domain.org {
root * /home/user/Code/ryan.dikdan.info
file_server
log {
output file /home/user/Code/caddy_log_output.txt
}
}