NGINX + PHP-FPM - Strange issue when trying to display images via php-gd / readfile - Connection wont terminate
- by anonymous-one
Ok, to get the details out of the way:
The php script can be anything as simple as:
<?
header('Content-Type: image/jpeg');
readfile('/local/image.jpg');
?>
When I try to execute this via nginx + php-fpm what happens is the image shows up in the browser, here is what happens:
IE - The page stays blank for a long period of time, and eventually the image is shown.
Chrome - The image shows, but the loading spinner spins and spins for a long period of time. Eventually the debugger will show the image in red as in error, but the image shows up fine.
Everything else on the server works great. Its pushing out about 100mbit steady serving static content. So this is definatly a php-fpm related issue.
I THINK this may have something to do with the chunked encoding being sent back wrong?
Also, I threw in a pause before the image was read, and got the pid of the fpm process, and it looks as tho its terminatly correctly (from strace):
shutdown(3, 1 /* send */) = 0
recvfrom(3, "\1\5\0\1\0\0\0\0", 8, 0, NULL, NULL) = 8
recvfrom(3, "", 8, 0, NULL, NULL) = 0
close(3) = 0
The above was dumped long before ie/chrome decided to give up (even tho the image was shown) loading the image.
Displaying HTML / text content is fine. Big bodies etc all load nice and fast and terminate right away (as they should).
Doing something like:
THIS IS THE IMAGE
---BINARY DUMP OF IMAGE---
Works fine too.
Any ideas?