Hi all,
after years not touching anything, I said that with your help I could finally jump on v2!
1. Caddy version (caddy version
):
Version 1
2. How I run Caddy:
qpkg installed and runs on QNAP at start.
Ports 443 and 80 are forwarded by the router to the server.
Everything works fine under v. 1, but I think it would be best practice and more secure to migrate everything to v. 2.
Honestly, I do not need all the log function if it could create problems.
a. System environment:
QNAP
b. Command:
…/.qpkg/Caddy/caddy.sh
#!/bin/sh
CONF=/etc/config/qpkg.conf
QPKG_NAME="Caddy"
QPKG_ROOT=`/sbin/getcfg $QPKG_NAME Install_Path -f ${CONF}`
APACHE_ROOT=`/sbin/getcfg SHARE_DEF defWeb -d Qweb -f /etc/config/def_share.info`
export QNAP_QPKG=$QPKG_NAME
export QPKG_ROOT
export QPKG_NAME
export APACHE_ROOT
export SHELL=/bin/sh
export LC_ALL=en_US.UTF-8
export USER=admin
export LANG=en_US.UTF-8
export LC_CTYPE=en_US.UTF-8
export CADDYPATH=/share/homes/user/caddy/Caddypath
ulimit -n 8192
export PIDF=/var/run/caddy.pid
case "$1" in
start)
ENABLED=$(/sbin/getcfg $QPKG_NAME Enable -u -d FALSE -f $CONF)
if [ "$ENABLED" != "TRUE" ]; then
echo "$QPKG_NAME is disabled."
exit 1
fi
/bin/ln -sf $QPKG_ROOT /opt/$QPKG_NAME
/bin/ln -sf $QPKG_ROOT/caddy /usr/bin/caddy
caddy -conf /share/homes/user/caddy/caddy.conf -agree -email nas@server.com -root /home/Qhttpd -log /share/homes/user/caddy/caddy.log -pidfile /var/run/caddy.pid &
;;
stop)
ID=$(more /var/run/caddy.pid)
if [ -e $PIDF ]; then
kill -9 $ID
rm -f $PIDF
fi
rm -rf /opt/$QPKG_NAME
rm -rf /usr/bin/caddy
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0
d. My complete Caddyfile or JSON config:
caddy.conf
(gzipconf) {
gzip {
ext *
level 7
min_length 1
}
}
(addheader) {
header / {
Strict-Transport-Security "max-age=31536000;"
X-XSS-Protection "1; mode=block"
X-Content-Type-Options "nosniff"
X-Frame-Options "SAMEORIGIN"
Referrer-Policy "strict-origin-when-cross-origin"
-Server
}
}
### server NAS
nas.server.com {
import gzipconf
import addheader
log / /share/homes/user/caddy/accesslogs/server-NAS.log "{hostonly} {combined} {latency_ms}"
proxy / http://192.168.10.5:8080 {
keepalive 32
transparent
websocket
}
}
3. The problem I’m having:
Help moving to version 2 (for the config file, as the sh would be upgraded by the new qpkg, and I think it would need simple customization.
4. Error messages and/or full log output:
Not tried yet as really afraid to break 20 and counting proxies…
5. What I already tried:
Reading the doc[1], but I am really bad at understanding JSON and necessary steps.
[1] Upgrading to Caddy 2 — Caddy Documentation