1. Caddy version (caddy version
):
v2.4.6 h1:HGkGICFGvyrodcqOOclHKfvJC0qTU7vny/7FhYp9hNw=
2. How I run Caddy:
systemctl start caddy (Failed)
caddy start (Success)
a. System environment:
Centos7
b. Command:
systemctl start caddy (Failed)
caddy start (Success)
c. Service/unit/compose file:
caddy.service
#
# 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
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:
aaa.aaa{
reverse_proxy 127.0.0.1:29584 {
}
}
aaa.aaa.aaa{
reverse_proxy 127.0.0.1:12580 {
}
}
aaa.aaa.aaa{
reverse_proxy aaa.aaa.aaa.aaa:aaa{
header_up Host aaa.aaa.aaa.aaa
}
}
aaa.aaa.aaa{
reverse_proxy aaa.aaa.aaa.aaa:aaa{
header_up Host aaa.aaa.aaa.aaa
}
}
aaa.aaa.aaa{
tls /aaa/aaa/aaa/aaa/server.pem /aaa/aaa/aaa/https/server.key
reverse_proxy /jquery-3.3* https://127.0.0.1:8443 {
transport http {
tls
tls_insecure_skip_verify
}
}
}
3. The problem I’m having:
I’m trying to start caddy service by using systemctl start caddy
, when caddy is initally installed, the default Caddyfile fits well and the caddy service lauched correctly, but when I use the Caddyfile above, the caddy service couldn’t launch. However, using the same command mentioned in the file caddy.service
goes well.
4. Error messages and/or full log output:
systemctl status caddy -l
goes like this:
â—Ź caddy.service - Caddy
Loaded: loaded (/usr/lib/systemd/system/caddy.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2022-01-13 13:23:56 CST; 14min ago
Docs: https://caddyserver.com/docs/
Process: 1312 ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile (code=exited, status=1/FAILURE)
Main PID: 1312 (code=exited, status=1/FAILURE)
Jan 13 13:23:56 important-pony-1.localdomain caddy[1312]: runtime.GOARCH=amd64
Jan 13 13:23:56 important-pony-1.localdomain caddy[1312]: runtime.Compiler=gc
Jan 13 13:23:56 important-pony-1.localdomain caddy[1312]: runtime.NumCPU=2
Jan 13 13:23:56 important-pony-1.localdomain caddy[1312]: runtime.GOMAXPROCS=2
Jan 13 13:23:56 important-pony-1.localdomain caddy[1312]: runtime.Version=go1.16.8
Jan 13 13:23:56 important-pony-1.localdomain caddy[1312]: os.Getwd=/
Jan 13 13:23:56 important-pony-1.localdomain systemd[1]: Started Caddy.
Jan 13 13:23:56 important-pony-1.localdomain systemd[1]: caddy.service: main process exited, code=exited, status=1/FAILURE
Jan 13 13:23:56 important-pony-1.localdomain systemd[1]: Unit caddy.service entered failed state.
Jan 13 13:23:56 important-pony-1.localdomain systemd[1]: caddy.service failed.
I tried the /usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
mentioned above and this time everything goes well:
2022/01/13 05:39:34.312 INFO using provided configuration {"config_file": "/etc/caddy/Caddyfile", "config_adapter": ""}
2022/01/13 05:39:34.316 WARN input is not formatted with 'caddy fmt' {"adapter": "caddyfile", "file": "/etc/caddy/Caddyfile", "line": 11}
2022/01/13 05:39:34.319 INFO admin admin endpoint started {"address": "tcp/localhost:2019", "enforce_origin": false, "origins": ["localhost:2019", "[::1]:2019", "127.0.0.1:2019"]}
2022/01/13 05:39:34.322 WARN tls stapling OCSP {"error": "no OCSP stapling for [cloudflare origin certificate *.aaa.aaa aaa.aaa]: no URL to issuing certificate"}
2022/01/13 05:39:34.323 INFO tls.cache.maintenance started background certificate maintenance {"cache": "0xc00037e070"}
2022/01/13 05:39:34.324 INFO http server is listening only on the HTTP port, so no automatic HTTPS will be applied to this server {"server_name": "srv1", "http_port": 80}
2022/01/13 05:39:34.326 INFO http skipping automatic certificate management because one or more matching certificates are already loaded {"domain": "aaa.aaa.aaa", "server_name": "srv0"}
2022/01/13 05:39:34.326 INFO http enabling automatic HTTP->HTTPS redirects {"server_name": "srv0"}
2022/01/13 05:39:34.327 INFO tls cleaning storage unit {"description": "FileStorage:/root/.local/share/caddy"}
2022/01/13 05:39:34.327 INFO http enabling automatic TLS certificate management {"domains": ["aaa.aaa.aaa", "aaa.aaa"]}
2022/01/13 05:39:34.331 INFO tls finished cleaning storage units
2022/01/13 05:39:34.346 INFO autosaved config (load with --resume flag) {"file": "/root/.config/caddy/autosave.json"}
2022/01/13 05:39:34.346 INFO serving initial configuration
5. What I already tried:
I’ve tried reinstall caddy and I found the default given Caddyfile fits well with the systemctl command , I guess there’s something wrong with my Caddyfile but I couldn’t figure out why it happened. Any hint would be appreicated.