This page shows around 500 images, each of which is generated using the same script with different parameters; you will note that after a while many of the images are missing:
https://cassland.org/images/Avatars/
The page is generated by a PHP script: https://sye.dk/sfpg/
I was not aware of this happening when the page was hosted on Apache. The author of the script prompted me to check the Caddy logs, with the following explanation:
Some servers have a limit that prevented the same script in running more
than x instances at the same time. And some also have a limit on how
much memory a script is allowed to consume, all simultaneously running
instances combined.The way this gallery works, the one script (index.php) acts as both HTML
and all images including thumbs. So loading a page with 100 thumbs, will
make 101 requests for the same file “index.php”, just with different
parameters.If you are on a hosted server, try ask them about these limits. If its
your own server, have a look in the web-server log, there will most
likely be an entry about this, when it happens.
And indeed the Caddy log is full of errors like these:
19/Feb/2018:12:11:11 +0000 [ERROR 502 /images/Avatars/index.php] dial tcp 127.0.0.1:9123: connectex: No connection could be made because the target machine actively refused it.
19/Feb/2018:12:11:11 +0000 [ERROR 502 /images/Avatars/index.php] dial tcp 127.0.0.1:9123: connectex: No connection could be made because the target machine actively refused it.
19/Feb/2018:12:11:11 +0000 [ERROR 502 /images/Avatars/index.php] dial tcp 127.0.0.1:9123: connectex: No connection could be made because the target machine actively refused it.
19/Feb/2018:12:11:11 +0000 [ERROR 502 /images/Avatars/index.php] dial tcp 127.0.0.1:9123: connectex: No connection could be made because the target machine actively refused it.
19/Feb/2018:12:11:11 +0000 [ERROR 502 /images/Avatars/index.php] dial tcp 127.0.0.1:9123: connectex: No connection could be made because the target machine actively refused it.
19/Feb/2018:12:11:11 +0000 [ERROR 502 /images/Avatars/index.php] dial tcp 127.0.0.1:9123: connectex: No connection could be made because the target machine actively refused it.
And for completeness, here is the section of the Caddyfile relating to that server:
cassland.org,
www.cassland.org {
root ..\cassland.org\html
browse /Album
browse /images
browse /sounds
browse /scores2
browse /Varicam
browse /TascamMod
# "startup" seems to hang on Windows, so I made php-cgi a service instead.
fastcgi / 127.0.0.1:9123 php
# proxy random image generators to Apache which knows what to do with them:
proxy /images/QCavi.jpg localhost:81 {
transparent
}
proxy /images/PJavi.jpg localhost:81 {
transparent
}
proxy /images/FireDog.jpg localhost:81 {
transparent
}
# password for Cherwell Singers pages:
basicauth /CherwellSingers xxxxx yyyyy
# password for private scores page:
basicauth /scores2 xxxxx yyyyy
# password for proxies:
basicauth xxxxx yyyyy {
realm "proxies"
/PP1
/PP2
}
log .\Logs\CLaccess.log
errors .\Logs\CLerror.log {
404 404.html
# 404 New404.html
}
}
Is there some configuration in Caddy (or, I suppose, in PHP perhaps) which I can set to ease this problem? The hosting machine is lightly loaded and has oodles of resources, though not a particularly fast processor. Changing the memory_limit for PHP made no difference (it is over ten times the size of all the data used in that page). Although the Caddy error seems to indicate that it is PHP refusing to cooperate, the PHP error log has no entries relating to this.
Paul