Reference configuration for caddy2 server
freefly42 opened this issue · comments
Kent Hulick commented
I've created a Caddyfile to enable using Caddy2 as the web server, and thought I would share. I'd suggest adding this as mythweb.conf.caddy.
# The Caddyfile is an easy way to configure your Caddy web server.
#
# Unless the file starts with a global options block, the first
# uncommented line is always the address of your site.
#
# To use your own domain name (with automatic HTTPS), first make
# sure your domain's A/AAAA DNS records are properly pointed to
# this machine's public IP, then replace ":80" below with your
# domain name.
# Global options https://caddyserver.com/docs/caddyfile/options
{
auto_https off
admin off
log {
output file /var/log/caddy/caddy.log {
roll_size 50
roll_keep 5
roll_keep_for 2d
}
format console
level INFO
#level DEBUG
}
}
:8080 {
# Set this path to your site's directory.
root * /usr/share/caddy/mythweb
# Add trailing slash for directory requests
@canonicalPath {
file {path}/mythweb.php
not path */
}
redir @canonicalPath {path}/ 308
# Enable the static file server.
file_server
# rewrite rules
@myth_do_nothing {
path_regexp myth_do_nothing_reg ^/(css|data|images|js|themes|skins|[a-z_]+\.(php|pl)).*
}
@myth_perl {
path_regexp myth_perl_reg ^/(pl(/.*)?)$
}
@myth_php {
path_regexp myth_php_reg ^/(.+)$
}
handle @myth_do_nothing {
#do nothing but keep other handlers from running
#rewrite @myth_do_nothing {http.regexp.myth_do_nothing_reg.0}
}
handle @myth_perl {
rewrite @myth_perl /mythweb.pl/{http.regexp.myth_perl_reg.1}
}
handle @myth_php {
rewrite @myth_php /mythweb.php/{http.regexp.myth_php_reg.1}
}
handle * {
rewrite * mythweb.php
}
# Proxy PHP files to the FastCGI responder
@phpFiles path *.php*
reverse_proxy @phpFiles unix//run/php/php7.4-fpm.sock {
transport fastcgi {
split .php
env db_server localhost
env db_name mythconverg
env db_login mythtv
env db_password mythtv
}
}
}
# Refer to the Caddy docs for more information:
# https://caddyserver.com/docs/caddyfile