1. Caddy version (caddy version
):
v2.2.1
2. How I run Caddy:
a. System environment:
Ubuntu 20.04
b. Command:
I first installed Caddy using
$ echo "deb [trusted=yes] https://apt.fury.io/caddy/ /" \
| sudo tee -a /etc/apt/sources.list.d/caddy-fury.list
$ sudo apt update
$ sudo apt install caddy
Then I use the following code to start Caddy as a service.
# systemctl start caddy
# systemctl enable caddy
# systemctl status caddy
c. Service/unit/compose file:
systemd 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]
User=caddy
Group=caddy
ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target
d. My complete Caddyfile or JSON config:
Caddyfile
ryanyao.xyz{
root * /var/www/
file_server
}
3. The problem I’m having:
The service is running, but I can’t access my domain.
4. Error messages and/or full log output:
caddy.HomeDir=/var/lib/caddy
Nov 27 22:53:21 server caddy[36067]: caddy.AppDataDir=/var/lib/caddy/.local/share/caddy
Nov 27 22:53:21 server caddy[36067]: caddy.AppConfigDir=/var/lib/caddy/.config/caddy
Nov 27 22:53:21 server caddy[36067]: caddy.ConfigAutosavePath=/var/lib/caddy/.config/caddy/autosave.json
Nov 27 22:53:21 server caddy[36067]: caddy.Version=v2.2.1
Nov 27 22:53:21 server caddy[36067]: runtime.GOOS=linux
Nov 27 22:53:21 server caddy[36067]: runtime.GOARCH=amd64
Nov 27 22:53:21 server caddy[36067]: runtime.Compiler=gc
Nov 27 22:53:21 server caddy[36067]: runtime.NumCPU=3
Nov 27 22:53:21 server caddy[36067]: runtime.GOMAXPROCS=3
Nov 27 22:53:21 server caddy[36067]: runtime.Version=go1.15.2
Nov 27 22:53:21 server caddy[36067]: os.Getwd=/
Nov 27 22:53:21 server caddy[36067]: LANG=en_US.UTF-8
Nov 27 22:53:21 server caddy[36067]: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
Nov 27 22:53:21 server caddy[36067]: HOME=/var/lib/caddy
Nov 27 22:53:21 server caddy[36067]: LOGNAME=caddy
Nov 27 22:53:21 server caddy[36067]: USER=caddy
Nov 27 22:53:21 server caddy[36067]: INVOCATION_ID=ff988eb69d09442a9d52daa2e5097070
Nov 27 22:53:21 server caddy[36067]: JOURNAL_STREAM=9:178256
Nov 27 22:53:21 server caddy[36067]: {"level":"info","ts":1606517601.846735,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":""}
Nov 27 22:53:21 server caddy[36067]: {"level":"info","ts":1606517601.849302,"logger":"admin","msg":"admin endpoint started","address":"tcp/localhost:2019","enforce_origin":false,"origins":["127.0.0.1:2019","localhost:2019","[::1]:2019"]}
Nov 27 22:53:21 server caddy[36067]: {"level":"info","ts":1606517601.8495014,"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}
Nov 27 22:53:21 server caddy[36067]: {"level":"info","ts":1606517601.8495169,"logger":"http","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"srv0"}
Nov 27 22:53:21 server caddy[36067]: {"level":"info","ts":1606517601.8523042,"msg":"autosaved config","file":"/var/lib/caddy/.config/caddy/autosave.json"}
Nov 27 22:53:21 server caddy[36067]: {"level":"info","ts":1606517601.8523262,"msg":"serving initial configuration"}
5. What I already tried:
I haven’t tried much, I don’t know why it won’t work. Looks like the server needs a TLS connection policy, but I don’t know what’s that means. I can’t find anything on the documentation as well.