Caddy config examples
Jump to navigation
Jump to search
Examples
install
#!/bin/bash set -eu # version=2.6.2 version=2.5.2 curl -LO https://github.com/caddyserver/caddy/releases/download/v${version}/caddy_${version}_linux_amd64.tar.gz \ && tar xzf caddy_${version}_linux_amd64.tar.gz \ && ./caddy version # https://github.com/caddyserver/caddy/releases/download/v2.6.2/caddy_2.6.2_linux_amd64.deb
Format & load
#!/bin/bash set -eux caddy fmt --overwrite a.caddy caddy adapt --config a.caddy > a.json # ./caddy run --config a.json curl localhost:2019/load -H "Content-Type: application/json" -d @a.json
Config example
{ # admin off admin :12019 http_port 8080 https_port 8443 } http://testlocal.uvoo.io:8080 { # Change the path here according to your setup # root * /var/www/domain.com # root * /home/busk/caddy/domains/localtest.uvoo.io root * ./domains/testlocal.uvoo.io encode zstd gzip file_server @cache { not header_regexp Cookie "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in" not path_regexp "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(index)?.xml|[a-z0-9-]+-sitemap([0-9]+)?.xml)" not method POST not expression {query} != '' } route @cache { try_files /wp-content/cache/cache-enabler/{host}{uri}/https-index.html /wp-content/cache/cache-enabler/{host}{uri}/index.html {path} {path}/index.php?{query} } # Change the path here according to your server php_fastcgi unix//run/php/php7.4-fpm.sock } http://testlocal1.uvoo.io:8080 { root * ./domains/testlocal1.uvoo.io encode zstd gzip file_server log { output file ./logs/testlocal1.uvoo.io.8080-access.log } } https://testlocal2.uvoo.io:8443 { root * ./domains/testlocal2.uvoo.io encode zstd gzip file_server tls ./certs/selfsigned.crt ./certs/selfsigned.key log { output file ./logs/testlocal2.uvoo.io.8443-access.log } }