Welcome! Log In Create A New Profile

Advanced

Re: How to disable output buffering with PHP and nginx

All files from this thread

File Name File Size   Posted by Date  
nginx.conf 2.7 KB open | download B.R. 10/07/2013 Read message
test.php 77 bytes open | download B.R. 10/07/2013 Read message
php.ini 67.3 KB open | download B.R. 10/07/2013 Read message
nginx_php_backend.pcapng 5.5 KB open | download B.R. 10/07/2013 Read message
Francis Daly
October 07, 2013 05:36PM
On Mon, Oct 07, 2013 at 03:22:15PM -0400, Ben Johnson wrote:
> On 9/16/2013 1:19 PM, Ben Johnson wrote:

Hi there,

> > For whatever reason, nginx *always* buffers the output, even when I set

> > Is it possible to disable PHP output buffering completely in nginx?

Have you shown that the initial problem is on the nginx side?

I suspect it will be more interesting to people on this list if you
have a simple test case which demonstrates that it is nginx which is
buffering when you don't want it to.

Use a php script like this:

==
<?
echo "The first bit";
sleep(5);
echo "The second bit";
?>
==

Run the fastcgi server like this:

env -i php-cgi -d cgi.fix_pathinfo=0 -q -b 9009

Use an nginx config which includes something like this:

==
location = /php {
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/test.php;
fastcgi_pass 127.0.0.1:9009;
}
==

Then do something like

tcpdump -nn -i any -A -s 0 port 9009

while also doing a

curl -i http://127.0.0.1:8080/php

and look at the network traffic from the fastcgi server.

If you don't see a five-second gap between the two different response
packets, it is being buffered before it gets to nginx.

Now make whichever please-don't-buffer changes seem useful in the php code
and in the fastcgi server configuration. When you can see non-buffered
output getting to nginx, then you know the non-nginx side is doing what
you want. So now you can start testing nginx configuration changes;
and you can share the exact non-nginx configuration you use, so that
someone else can copy-paste it and see the same problem that you see.

(Change 127.0.0.1:9009 to be whatever remote server runs your fastcgi
server, if that makes it easier to run tcpdump.)

Good luck with it,

f
--
Francis Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

How to disable output buffering with PHP and nginx

Ben Johnson September 16, 2013 01:22PM

Re: How to disable output buffering with PHP and nginx

Ben Johnson October 07, 2013 03:24PM

Re: How to disable output buffering with PHP and nginx

itpp2012 October 07, 2013 04:25PM

Re: How to disable output buffering with PHP and nginx

Francis Daly October 07, 2013 05:36PM

Re: How to disable output buffering with PHP and nginx

B.R. October 07, 2013 06:00PM

Re: How to disable output buffering with PHP and nginx

Maxim Dounin October 07, 2013 07:20PM

Re: How to disable output buffering with PHP and nginx Attachments

B.R. October 07, 2013 11:00PM

Re: How to disable output buffering with PHP and nginx

Maxim Dounin October 08, 2013 11:50AM

Re: How to disable output buffering with PHP and nginx

Ben Johnson October 10, 2013 11:14AM

Re: How to disable output buffering with PHP and nginx

Maxim Dounin October 10, 2013 11:28AM

Re: How to disable output buffering with PHP and nginx

Ben Johnson October 10, 2013 12:50PM

Re: How to disable output buffering with PHP and nginx

itpp2012 October 10, 2013 01:35PM

Re: How to disable output buffering with PHP and nginx

Maxim Dounin October 10, 2013 02:26PM

Re: How to disable output buffering with PHP and nginx

Ben Johnson October 12, 2013 04:40PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

mrw
Guests: 56
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready