From e732858975505076ce35e145516b3ac201d35f17 Mon Sep 17 00:00:00 2001 From: Basil Hendroff <63370329+basilhendroff@users.noreply.github.com> Date: Sun, 23 May 2021 14:14:21 +0800 Subject: [PATCH 1/4] Update wordpress-jail.sh Use Caddy pkg - a more standardised approach - daemonise - compliant rc.d scripting --- wordpress-jail.sh | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/wordpress-jail.sh b/wordpress-jail.sh index 3534e60..90124d6 100755 --- a/wordpress-jail.sh +++ b/wordpress-jail.sh @@ -148,7 +148,7 @@ cat <<__EOF__ >/tmp/pkg.json "php74-ftp","php74-pecl-ssh2","php74-sockets", "mariadb105-server","unix2dos","ssmtp","phpmyadmin5-php74", "php74-xmlrpc","php74-ctype","php74-session","php74-xmlwriter", - "redis","php74-pecl-redis","php74-phar" + "redis","php74-pecl-redis","php74-phar","caddy" ] } __EOF__ @@ -176,24 +176,6 @@ iocage fstab -a "${JAIL_NAME}" "${FILES_PATH}" /usr/local/www/wordpress nullfs iocage exec "${JAIL_NAME}" mkdir -p /mnt/includes iocage fstab -a "${JAIL_NAME}" "${INCLUDES_PATH}" /mnt/includes nullfs rw 0 0 -##################################################################### -print_msg "Caddy download..." - -CADDY_VERSION="2.4.1" - -FILE="caddy_${CADDY_VERSION}_freebsd_amd64.tar.gz" -if ! iocage exec "${JAIL_NAME}" fetch -o /tmp https://github.com/caddyserver/caddy/releases/download/v"${CADDY_VERSION}"/"${FILE}" -then - print_err "Failed to download Caddy" - exit 1 -fi -if ! iocage exec "${JAIL_NAME}" tar xzf /tmp/"${FILE}" -C /usr/local/bin/ -then - print_err "Failed to extract Caddy" - exit 1 -fi -iocage exec "${JAIL_NAME}" rm /tmp/"${FILE}" - ##################################################################### print_msg "Wordpress download..." @@ -321,10 +303,11 @@ print_msg "Configure and start Caddy..." # Copy and edit pre-written config files iocage exec "${JAIL_NAME}" cp -f /mnt/includes/Caddyfile /usr/local/www -iocage exec "${JAIL_NAME}" cp -f /mnt/includes/caddy /usr/local/etc/rc.d/ +iocage exec "${JAIL_NAME}" sed -i '' "s|configtest|validate|" /usr/local/etc/rc.d/caddy iocage exec "${JAIL_NAME}" sysrc caddy_enable="YES" iocage exec "${JAIL_NAME}" sysrc caddy_config="/usr/local/www/Caddyfile" +iocage exec "${JAIL_NAME}" sysrc caddy_logdir="/var/log" iocage exec "${JAIL_NAME}" service caddy start From e4759e2e9bb3a85208a444ae55d1071826bfafe3 Mon Sep 17 00:00:00 2001 From: Basil Hendroff <63370329+basilhendroff@users.noreply.github.com> Date: Sun, 23 May 2021 14:24:47 +0800 Subject: [PATCH 2/4] Update Caddyfile - Add zstd encode - iso8601 time standard --- includes/Caddyfile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/includes/Caddyfile b/includes/Caddyfile index 092e9e3..af38f56 100644 --- a/includes/Caddyfile +++ b/includes/Caddyfile @@ -1,6 +1,14 @@ +{ + log { + format json { + time_format iso8601 + } + } +} + :80 { root * /usr/local/www/wordpress - encode gzip + encode gzip zstd php_fastcgi 127.0.0.1:9000 { env SERVER_PORT 80 } From 36092f9d44d545c9abbb177740c5964ea5383588 Mon Sep 17 00:00:00 2001 From: Basil Hendroff <63370329+basilhendroff@users.noreply.github.com> Date: Sun, 23 May 2021 14:26:06 +0800 Subject: [PATCH 3/4] Delete caddy No longer required. Now using caddy pkg install. --- includes/caddy | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) delete mode 100755 includes/caddy diff --git a/includes/caddy b/includes/caddy deleted file mode 100755 index 45f6cc9..0000000 --- a/includes/caddy +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/sh -# -# $FreeBSD$ -# - -# PROVIDE: caddy -# REQUIRE: LOGIN DAEMON NETWORKING -# KEYWORD: shutdown - -# Add the following lines to /etc/rc.conf.local or /etc/rc.conf -# to enable this service: -# caddy_enable (bool): Set to NO by default. Set it to YES to enable caddy. -# -# caddy_config (string): Optional full path for caddy config file -# caddy_adapter (string): Optional adapter type if the configuration is not in caddyfile format -# caddy_extra_flags (string): Optional flags passed to caddy start -# caddy_logfile (string): Set to "/var/log/caddy.log" by default. -# Defines where the process log file is written, this is not a web access log - -. /etc/rc.subr - -name=caddy -rcvar=caddy_enable -desc="Caddy 2 is a powerful, enterprise-ready, open source web server with automatic HTTPS written in Go" - -load_rc_config $name - -# Defaults -: ${caddy_enable:=NO} -: ${caddy_config:="/usr/local/etc/Caddyfile"} -: ${caddy_adapter:=caddyfile} -: ${caddy_extra_flags:=""} -: ${caddy_logfile="/var/log/caddy.log"} - -command="/usr/local/bin/${name}" -caddy_flags="--config ${caddy_config} --adapter ${caddy_adapter}" -pidfile="/var/run/${name}.pid" - -required_files="${caddy_config} ${command}" - -# Extra Commands -extra_commands="validate reload" -start_cmd="${command} start ${caddy_flags} ${caddy_extra_flags} --pidfile ${pidfile} >> ${caddy_logfile} 2>&1" -validate_cmd="${command} validate ${caddy_flags}" -reload_cmd="${command} reload ${caddy_flags}" - -run_rc_command "$1" From 7de27fa60cd4b7ea35f38e91c82f0475fbb02bcd Mon Sep 17 00:00:00 2001 From: Basil Hendroff <63370329+basilhendroff@users.noreply.github.com> Date: Sun, 23 May 2021 17:49:26 +0800 Subject: [PATCH 4/4] Update Caddyfile Not compatible with Caddy 2.3.0 --- includes/Caddyfile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/includes/Caddyfile b/includes/Caddyfile index af38f56..470110c 100644 --- a/includes/Caddyfile +++ b/includes/Caddyfile @@ -1,11 +1,11 @@ -{ - log { - format json { - time_format iso8601 - } - } -} - +#{ +# log { +# format json { +# time_format iso8601 +# } +# } +#} +# :80 { root * /usr/local/www/wordpress encode gzip zstd