Software, Web Development

Nginx Truncating Any Web Page With or Without PHP

I had a problem recently (or rather, just now) whereby one of my Nginx installs was truncating PHP pages.

I soon figured out it was because Nginx was actually showing me the in-memory buffer output and cutting off file buffer. You see Nginx will first try and load your entire page into memory, when failing this it will pump the output to a file.

The problem is if Nginx cannot write to that file for some reason it will only give you the first in-memory output of a page.

The way to find out if this is happening to you and how to solve it is detailed here: http://derekneely.com/2009/06/nginx-failed-13-permission-denied-while-reading-upstream/ but I will summarise it here to prevent link rot.

Your error.log should have a line like:

2014/07/08 08:19:25 [crit] 30100#0: *308814 open() "/var/lib/nginx/fastcgi/0/11/0000005110" failed (13: Permiss ion denied) while reading upstream, client: xx.xxx.xxx.xxx, server: localhost, request: "GET /xxxx/xxxx-xxxx  HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "xxxx.com", referrer: "http://xxxx.com/xxx/xxx"

And put simply, double check the permissions of your folders/files in: /var/lib/nginx/fastcgi, there is a very good chance they are not of the right permissions.