This question is sort of a post-mortem for an issue we had with a dv hosted by Media Temple. We had been experiencing random issues with our webserver (nginx running as reverse proxy on top of apache) experiencing app-wide 504 timeout errors intermittently. During the course of trying to troubleshoot this issue, I consulted with various MT agents over chat to try and find the source. During one such debugging session, an agent suggested trying to increase the nginx fastcgi buffer sizes through the Plesk Web UI for adding additional directives to nginx config. He added these lines:

location ~ .php$ {
  fastcgi_buffer_size 128k;
  fastcgi_buffers 4 256k;
  fastcgi_busy_buffers_size 256k;

I don't remember what the reasoning was behind increasing these values, which default to much smaller sizes.

Later on down the road, I happened to try typing in a direct URL to one of our index files on the app root, /franchisee.php. Typically the URL omits the .php part and .htaccess strips it out using mod_rewrite. To my surprise, my browser downloaded the file - didn't even make it as far as .htaccess.

After MT couldn't figure out what was causing the download issues, eventually getting Plesk to SSH into our box to figure out, we finally got a resolution in the form of advice to remove the above block from nginx config. And bingo: no more downloaded PHP files. But I couldn't get a straight answer as to why these particular directives would indicate to nginx to offer the files for download instead of parsing and processing them server-side (the response to my question of "Why did adding buffer size directives tell nginx to offer the file for download?" was: "The issue was likely causing the files to download because the entries were essentially telling the server to process php files as downloads rather than rendering the file as a webpage script."

So, my question is... what do buffer sizes have to do with how nginx interprets a file? I realize that buffering would involve storing data on the filesystem temporarily but why would that indicate offering a file to be downloaded over HTTPS?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.