Hi, I am in need of Caddy 2 Config Caddyfile sample code for 2 WordPress websites. Thank you!
Hi, welcome. Please see our wiki: Example: WordPress
This was recently reported to be a minimal working config.
So, for two domains should I do like this?
example1.com
root * /var/www/wordpress1
example2.com
root * /var/www/wordpress2
php_fastcgi unix//run/php/php-version-fpm.sock
file_server
When you have more than one site to serve, you need to wrap the site block with { }
braces
example1.com {
root * /var/www/wordpress1
php_fastcgi unix//run/php/php-version-fpm.sock
file_server
}
example2.com {
root * /var/www/wordpress2
php_fastcgi unix//run/php/php-version-fpm.sock
file_server
}
You could also make use of snippets to avoid copying the same directives multiple times.
okay thank you very much! You are awesome!!
However, can you please confirm if these whole code is correct for v2:
example1.com{
tls admin@example1.com
root * /var/www/html/example1
php_fastcgi unix//var/opt/remi/php74/run/php-fpm/www.sock
gzip
file_server
errors /var/log/caddy/error1.log
}
example2.com {
tls admin@example2.com
root * /var/www/html/example2
php_fastcgi unix//var/opt/remi/php74/run/php-fpm/www.sock
gzip
file_server
errors /var/log/caddy/error2.log
}
rewrite {
r /uploads\/(.*)\.php
to /
}
rewrite {
if {path} not_match ^\/wp-admin
to {path} {path}/ /index.php?_url={uri}
}
expires {
match .(ico|pdf|jpg|jpeg|png|gif|svg|css|js|ttf|eot|woff)$ 2m
}
If not, please help me make up.
Please use ``` before and after your config when you post it so it preserves whitespace, it’s very difficult to follow without indentation. You can also use the caddy fmt
command in Caddy v2 to output your config with fixed indentation!
Please take a look at the Caddy v2 upgrade guide, you’re still using Caddy v1 syntax in that config:
I don’t think either of the rewrites you have there are necessary, and they won’t work regardless when placed outside a site block, that’s not valid syntax.
Just for someone who has hardship in configuring WordPress on Caddy v2. Here are the working configurations for Caddyfile:
example1.com {
tls /etc/letsencrypt/live/example1.com/fullchain.pem /etc/letsencrypt/live/example1.com/privkey.pem
root * /var/www/html/example1
php_fastcgi unix//var/opt/remi/php74/run/php-fpm/www.sock
encode gzip
file_server
header Strict-Transport-Security max-age=5184000;
log {
output file /var/log/caddy/example1.log
#format console
}
}
example2.com {
tls /etc/letsencrypt/live/example2.com/fullchain.pem /etc/letsencrypt/live/example2.com/privkey.pem
root * /var/www/html/example2
php_fastcgi unix//var/opt/remi/php74/run/php-fpm/www.sock
encode gzip
file_server
header Strict-Transport-Security max-age=5184000;
log {
output file /var/log/caddy/example2.log
#format console
}
}
My WordPress websites are up and running on Caddy now. Thank you very much!!
I don’t understand, why would you use Let’s Encrypt and not let Caddy do all the work ?
You can delete the tls lines and also uninstall certbot, Caddy will do all that automatically for you.
It could be behind a reverse_proxy , where reverse_proxy obtain all the cert,
then wordpress server will obtain cert from reverse_proxy server to remain the HTTPS status
I was going to do that, but having hardtime making Nextcloud running v1 to work with reverse_proxy running v2.
i didn’t understand why you need https in local connection. it will increase overhead.
use http in your server and let caddy do the rest.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.