pkg install wgetcdmkdir caddycd caddywget -O caddy.tar.gz "https://caddyserver.com/download/freebsd/amd64?plugins=http.cache,http.cgi,http.jwt,http.login,tls.dns.cloudflare&license=personal&telemetry=on"tar zxvf caddy.tar.gzcp -rp caddy /usr/local/bincd init/freebsdcp caddy /usr/local/etc/rc.d
echo "caddy_enable=YES" >> /etc/rc.confcat /etc/rc.conf# Validate the line is therenetdata_enable=YEScaddy_enable=YES
vi /usr/local/etc/rc.d/caddyroot@phoenix:/usr/local/etc/rc.d # cat caddy#!/bin/sh## PROVIDE: caddy# REQUIRE: networking# KEYWORD: shutdown## Add the following lines to /etc/rc.conf to enable caddy:# caddy_enable (bool): Set to "NO" by default.# Set it to "YES" to enable caddy## caddy_cert_email (str): Set to "" by default.# Defines the SSL certificate issuer email. By providing an# email address you automatically agree to letsencrypt.org's# general terms and conditions## caddy_bin_path (str): Set to "/usr/local/bin/caddy" by default.# Provides the path to the caddy server executable## caddy_cpu (str): Set to "99%" by default.# Configures, how much CPU capacity caddy may gain## caddy_config_path (str): Set to "/usr/local/www/Caddyfile" by default.# Defines the path for the configuration file caddy will load on boot## caddy_user (str): Set to "root" by default.# Defines the user that caddy will run on## caddy_group (str): Set to "wheel" by default.# Defines the group that caddy files will be attached to## caddy_logfile (str) Set to "/var/log/caddy.log" by default.# Defines where the process log file is written, this is not a web access log## caddy_env (str) Set to "" by default.# This allows environment variable to be set that may be required, for example when using "DNS Challenge" account credentials are required.# e.g. (in your rc.conf) caddy_env="CLOUDFLARE_EMAIL=me@domain.com CLOUDFLARE_API_KEY=my_api_key"#. /etc/rc.subrcaddy_env="CLOUDFLARE_API_KEY=someAPIKEY CLOUDFLARE_EMAIL=someone@gmail.com"name="caddy"rcvar="${name}_enable"load_rc_config ${name}: ${caddy_enable:="NO"}: ${caddy_cert_email="someone@gmail.com"}: ${caddy_bin_path="/usr/local/bin/caddy"}: ${caddy_cpu="99%"} # was a bug for me that caused a crash within jails: ${caddy_config_path="/var/lib/caddy/Caddyfile"}: ${caddy_logfile="/var/lib/caddy/logs/caddy.log"}: ${caddy_user="root"}: ${caddy_group="wheel"}if [ "$caddy_cert_email" = "" ]then echo "rc variable \$caddy_cert_email is not set. Please provide a valid SSL certificate issuer email." exit 1fipidfile="/var/run/${name}.pid"procname="${caddy_bin_path}" #enabled builtin pid checking for start / stopcommand="/usr/sbin/daemon"command_args="-p ${pidfile} /usr/bin/env ${caddy_env} ${procname} -cpu ${caddy_cpu} -log stdout -conf ${caddy_config_path} -agree -email ${caddy_cert_email} < /dev/null >> ${caddy_logfile} 2>&1"start_precmd="caddy_startprecmd"caddy_startprecmd(){ if [ ! -e "${pidfile}" ]; then install -o "${caddy_user}" -g "${caddy_group}" "/dev/null" "${pidfile}" fi if [ ! -e "${caddy_logfile}" ]; then install -o "${caddy_user}" -g "${caddy_group}" "/dev/null" "${caddy_logfile}" fi}required_files="${caddy_config_path}"run_rc_command "$1"
root@phoenix:/var/lib/caddy # lsCaddyfile logs ssl
# Plex Serverplex.somewhere.us {gziptimeouts nonelog /opt/caddy/logs/plex.logtls { dns cloudflare}proxy / 127.0.0.1:32400 { transparent websocket }}
https://rutorrent.domain.us {gziplog /var/lib/caddy/logs/rutorrent.logtls { dns cloudflare}jwt { path / redirect /login?backTo={rewrite_uri} except /favicon.ico allow email admin@domain.us log-file /var/lib/caddy/logs/jwt.log log-level info} login { redirect_check_referer false google client_id=clientidhere,client_secret=clientsecret,scope=https://www.googleapis.com/auth/userinfo.email jwt_expiry 168h cookie_expiry 2400h }proxy / http://192.168.1.30 { transparent }}
: ${caddy_logfile="/var/lib/caddy/logs/caddy.log"}
# caddy_syslog_facility (str) Set to "local7" by default.# Defines the syslog facility used to log output from the caddy process.# This is NOT the web access log.## caddy_syslog_level (str) Set to "notice" by default.# Defines the syslog level used to log output from the caddy process.# This is NOT the web access log....: ${caddy_syslog_facility="local7"}: ${caddy_syslog_level="notice"}
log /var/lib/caddy/caddyservice.log
: ${caddy_logfile="/var/lib/caddy/caddy.log"}
acme: error cleaning up: cloudflare: failed to find zone domain.tld.: ListZonesContext command failed: error from makeRequest: HTTP status 400: content "{\"success\":false,\"errors\":[{\"code\":6003,\"message\":\"Invalid request headers\",\"error_chain\":[{\"code\":6102,\"message\":\"Invalid format for X-Auth-Email header\"},{\"code\":6103,\"message\":\"Invalid format for X-Auth-Key header\"}]}],\"messages\":[],\"result\":null}"
acme: error presenting token: cloudflare: failed to find zone domain.tld.: ListZonesContext command failed: error from makeRequest: HTTP status 400: content "{\"success\":false,\"errors\":[{\"code\":6003,\"message\":\"Invalid request headers\",\"error_chain\":[{\"code\":6102,\"message\":\"Invalid format for X-Auth-Email header\"},{\"code\":6103,\"message\":\"Invalid format for X-Auth-Key header\"}]}],\"messages\":[],\"result\":null}"