I’m trying to migrate a WordPress website from Caddy v1 to Caddy v2. The website doesn’t work as it should (it loads, but anything with a query in the URL isn’t parsed).
Whenever I try to use the administration, and it has a query on the URL, it doesn’t work either, trying to process the query for about 5 mins, then dropping it.
It worked just fine with Caddy v1:
:9001 {
root C:/Users/Ryan/www/wp
gzip
fastcgi / 127.0.0.1:9000
rewrite {
if {path} not_match ^\/wp-admin
to {path} {path}/ /index.php?{query}
}
}
4. Error messages and/or full log output:
Multiple HTTP Error 500 after the server timeout.
5. What I already tried:
It seems to be related to the if {path} not_match ^\/wp-admin directive and the {query} placeholder used in the old v1 Caddyfile. I’ve tried to replicate the config under v2 after reading the docs multiple times, to no avail:
:9001 {
root * C:/Users/Ryan/www/wp
# Add trailing slash for directory requests
@canonicalPath {
file {
try_files {path}/index.php
}
not {
path */
}
}
redir @canonicalPath {path}/ 308
# If the requested file does not exist, try index files
@wp_rewrite {
not {
path /wp-admin/*
file {
try_files {path} {path}/index.php?{query} index.php?{query}
}
}
}
rewrite @wp_rewrite {http.matchers.file.relative}
# Proxy PHP files to the FastCGI responder
@phpFiles {
path *.php
}
reverse_proxy @phpFiles 127.0.0.1:9000 {
transport fastcgi {
split .php
}
}
encode gzip
file_server
}
To clarify, I think that simple Caddyfile should work just fine. For context, another user confirmed recently that it worked for them:
The only thing you might want to add is a rule to block .php files from the /uploads directory:
respond /uploads/*.php 404
I feel that the HTTP 500 error is unrelated to the way Caddy is passing the request to your server, but instead some other issue. Best to find the error logs and see what it says.
My bad, I thought you were referring to the Caddy log. The PHP-FPM error log just repeats itself over and over:
[06-Apr-2020 18:00:58 UTC] PHP Fatal error: Maximum execution time of 30 seconds exceeded in C:\Users\Ryan\www\wp\wp-includes\Requests\Transport\cURL.php on line 163
[06-Apr-2020 18:03:59 UTC] PHP Fatal error: Maximum execution time of 30 seconds exceeded in C:\Users\Ryan\www\wp\wp-includes\Requests\Transport\cURL.php on line 163
[06-Apr-2020 18:04:02 UTC] PHP Fatal error: Maximum execution time of 30 seconds exceeded in C:\Users\Ryan\www\wp\wp-includes\Requests\Transport\cURL.php on line 163
I have the cURL extension enabled, and cURL installed in Windows.
Okay, then that’s definitely not an issue with Caddy, that means that your cron is attempting to make an HTTP request using curl to somewhere but it’s timing out. Maybe you can add a debug line just before that spot to see what the request address is that your code is trying to hit? Something like error_log($url); I don’t know the WordPress codebase very well.
Thank you!
I’ve solved the issue by checking the URLs being fetched via cURL, and the Hummingbird plugin (WordPress) was stuck in a loop calling the URLs over and over.
As you’ve said, this has nothing to do with Caddy v2, but it was somehow working with v1.
Quick update on the issue: WordPress 5.4 seems to not be fully compatible with PHP 7.4 just yet. This seems to definitely be the issue, as downgrading to 7.3.15 solved every single problem.