I’m working on a Statamic website project using Caddy FastCGI PHP as replacment for a local Apache installation
I just have to reload some pages a few times in my browser and I get those error messages
09/Nov/2016:21:26:44 +0100 [ERROR 502 /index.php/] http: request method or response status code does not allow body
09/Nov/2016:21:29:30 +0100 [ERROR 502 /index.php/] read tcp 127.0.0.1:56452->127.0.0.1:8000: wsarecv: An existing connection was forcibly closed by the remote host.
It seems that some return values cause the FastCGI addon to crash … or whatever …
The moment that happens I’m forced to shutdown Caddy and restart because nothing works anymore.
Currently switched to NGINX for local development because Caddy freezes too often on my local dev machine.
Hit F5 in your browser to refresh a couple of times and it stucks.
Tried it without and with pool setting, no difference …
No special settings, id say… file_get_content, not that I remember this second
I had to do a full source review to see as I can’t remember right now.
Some JS ajax calls and an ordinary PHP website.
I have another Caddy hosting on a VPS, there I host a static HTML website with 1 x single PHP file which does indeed use file_get_contents ( just a few lines of code ) and all few days I have to restart Caddy as a PHP error is in a non recoverable state and PHP doesn’t work anymore, although Caddy instance still runs.
What request is being made to Caddy that it’s trying to return a 502 on, exactly? With that rewrite any request to any path without a file extension could be getting directed to fastcgi.
Small note but
fastcgi / 127.0.0.1:8000 php {
ext .php
split .php
index index.php
pool 100
}
is a tad redundant - the php preset is equal to the first three lines in the braces.
Thanks for the hint about the wrong setting with the [php] preset.
But even when I remove the three obsolete .php preset settings …
I just trigger F5 x 4 times and the local website doesn’t load anymore … or tries to load forever …
24/Nov/2016:11:39:31 +0100 [ERROR 502 /index.php/] dial tcp 127.0.0.1:8000: connectex: No connection could be made because the target machine actively refused it.
24/Nov/2016:11:39:54 +0100 [ERROR 502 /index.php/] write tcp 127.0.0.1:80->127.0.0.1:63238: wsasend: An existing connection was forcibly closed by the remote host.
The VPS deployment stucks with a 503 error on that single php file.
No worries - but I didn’t mean to imply they were incorrect, merely redundant. Removing the three lines only shortens your Caddyfile, it doesn’t make any real changes to the configuration.
My hunch at the moment is that there are requests that are being rewritten to the php index that perhaps shouldn’t be or are otherwise malformed.
This block:
rewrite {
regexp .*
ext /
to /index.php/{1}
}
Seems really odd to me. Usually in this instance I’d expect to see something like to /index.php{uri} - you’ve got a pattern match here (the {1}) but you don’t have any matching groups in the regexp.
There’s not a lot of things that trigger this, honestly. I’d wager it has something to do with this, that the request is a type PHP can’t handle, and it can’t return an error page because the request doesn’t allow it. If you can figure out what the specific request is, it’ll probably clarify a few things.
To clarify, I use regexp’s and php-fpm as well, including rewriting to php, in some of my sites, and have not run into this issue. My regexps are always much more specific than .*, though.
Caddy also has to be restarted when PHP returns an ERROR 502 /…/…php dial : connectex No connection could be made target machine refused it … After that error it doesn’t recover and I’m forced to kill / restart
On Windows, you should use PHP 7.1 as it can spawn more than 1 process.
You need to set PHP_FCGI_CHILDREN=3 (or more) before PHP launch.
Please try this, I had many 502 before this version (I used PHP 7.1 RC for quite some time)…