Skip to content

Instantly share code, notes, and snippets.

@ryanburnette
Created May 21, 2020 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanburnette/89ea0796710d36315f8b3f52d6f3e87f to your computer and use it in GitHub Desktop.
Save ryanburnette/89ea0796710d36315f8b3f52d6f3e87f to your computer and use it in GitHub Desktop.
nested WordPress instances with Caddy
[hostname] {
encode gzip
log {
output file /var/log/caddylog
}
@canonicalPath {
file {
try_files {path}/index.php
}
not path */
}
@altsite1 {
file {
try_files {path} {path}/index.php /altsite1{path} /altsite1/index.php
split_path .php
}
path /altsite1/*
}
@altsite2 {
file {
try_files {path} {path}/index.php /altsite2{path} /altsite2/index.php
split_path .php
}
path /altsite2/*
}
@rootsite {
file {
try_files {path} {path}/index.php index.php
split_path .php
}
not path /altsite1/*
not path /altsite2/*
}
@phpFiles {
path *.php
}
route {
redir @canonicalPath {path}/ 308
rewrite @altsite1 {http.matchers.file.relative}
rewrite @altsite2 {http.matchers.file.relative}
rewrite @rootsite {http.matchers.file.relative}
reverse_proxy @phpFiles unix//var/run/php/php-fpm.sock {
transport fastcgi {
split .php
}
}
}
root * /srv/wordpress/
file_server
}
@coolaj86
Copy link

You'll have to explain this to me.

Caddyfile supports comments, does't it?

@ryanburnette
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment