1. Output of caddy version
:
v2.6.2 h1:wKoFIxpmOJLGl3QXoo6PNbYvGW4xLEgo32GPBEjWL8o=
2. How I run Caddy:
systemctl start caddy
a. System environment:
CentOS7
b. Command:
systemctl restart caddy
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
User=caddy
Group=caddy
ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile --force
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target
d. My complete Caddy config:
(handle_log) {
log {
output file /etc/caddy/logs/caddy2.log
level INFO
}
}
(handle_errors) {
handle_errors {
respond "{http.error.status_code} {http.error.status_text}"
}
}
www.tigerice.cn {
encode gzip
import handle_errors
import handle_log
route /merchant/* {
uri strip_prefix /merchant
file_server {
root /opt/twomicro_v2/web/merchant
browse
disable_canonical_uris
}
}
file_server * {
root /var/www/html
}
@nacos path /nacos /nacos*
reverse_proxy @nacos {
header_up Host {http.reverse_proxy.upstream.hostport}
header_down Access-Control-Allow-Origin *
header_down Access-Control-Allow-Methods GET,POST,OPTIONS
header_down Access-Control-Allow-Headers *
to http://127.0.0.1:8848
}
}
3. The problem I’m having:
Caddy Log time is not CentOS7 time, time synchronization. Make caddy time consistent with OS time.
4. Error messages and/or full log output:
caddy2.log
2022/11/23 06:12:54.999 info admin.api received request {"method": "POST", "host": "localhost:2019", "uri": "/stop", "remote_ip": "127.0.0.1", "remote_port": "45188", "headers": {"Accept-Encoding":["gzip"],"Content-Length":["0"],"Origin":["http://localhost:2019"],"User-Agent":["Go-http-client/1.1"]}}
2022/11/23 06:12:54.999 warn admin.api exiting; byeee!! 👋
2022/11/23 06:12:55.000 info tls.cache.maintenance stopped background certificate maintenance {"cache": "0xc000393420"}
2022/11/23 06:12:55.001 info admin stopped previous server {"address": "localhost:2019"}
2022/11/23 06:12:55.001 info admin.api shutdown complete {"exit_code": 0}
2022/11/23 06:39:08.048 info http.log.access.log0 handled request {"request": {"remote_ip": "43.143.173.96", "remote_port": "46812", "proto": "HTTP/1.1", "method": "GET", "host": "www.tigerice.cn", "uri": "/nacos/", "headers": {"Accept": ["*/*"], "User-Agent": ["curl/7.29.0"]}, "tls": {"resumed": false, "version": 771, "cipher_suite": 49195, "proto": "", "server_name": "www.tigerice.cn"}}, "user_id": "", "duration": 0.002804804, "size": 2624, "status": 200, "resp_headers": {"Content-Language": ["en-US"], "Content-Type": ["text/html;charset=UTF-8"], "Last-Modified": ["Wed, 28 Jul 2021 11:28:44 GMT"], "Accept-Ranges": ["bytes"], "Date": ["Wed, 23 Nov 2022 06:39:07 GMT"], "Content-Length": ["2624"], "Server": ["Caddy"], "Alt-Svc": ["h3=\":443\"; ma=2592000"]}}
journalctl --no-pager -u caddy
Nov 23 15:31:14 VM-8-9-centos caddy[31058]: {"level":"info","ts":1669188674.4583886,"msg":"autosaved config (load with --resume flag)","file":"/var/lib/caddy/.config/caddy/autosave.json"}
Nov 23 15:31:14 VM-8-9-centos caddy[31058]: {"level":"info","ts":1669188674.4584343,"msg":"serving initial configuration"}
Nov 23 15:31:14 VM-8-9-centos caddy[31058]: {"level":"info","ts":1669188674.458686,"logger":"tls","msg":"finished cleaning storage units"}
Nov 23 15:31:37 VM-8-9-centos caddy[31058]: 2022-11-23 15:31:37.23030674 +0800 CST m=+22.796086578 write error: can't rename log file: rename /etc/caddy/logs/caddy2.log /etc/caddy/logs/caddy2-2022-11-23T07-31-37.230.log: read-only file system
5. What I already tried:
i have aready assigned write permission to caddy2.log, but it was not work well.