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
B.R.
October 07, 2013 11:00PM
I took a bit of time to do that... TBH I lost a lot of time finding a way
to record traffic to a locally hosted Web server in Windows... :o\
Why would people host stuff with Windows? oO

Anyway. Here are the details:

Configuration:
nginx 1.5.6
PHP 5.4.20 Thread-Safe
Wireshark 1.10.2
I took the liberty of upgrading test components to the latest release in
the same branch, since some bugs of interest might have been corrected.

Synthesis:
I didn't go far on the PHP side, but I noticed on early captures that PHP
was still sending everything after 5 seconds.

I cheated a little bit by modifying the test file to use the PHP flush()
procedure which forces buffers to be emptied and content sent to the client..

I then noticed on the capture that PHP was rightfully sending the content
in 2 parts as expected but somehow nginx was still waiting for the last
parto to arrive before sending content to the client.

There is still work to be done on the nginx side. Since we are on the nginx
mailing list, you may prioritize and see to the PHP part later on. :o)

Every modification I made to the original nginx.conf file is self-contained
in the location serving '.php' files.
How to reproduce:
The main concern here was to record traffic between nginx and PHP. Here are
the steps for a successful operation.


1. Use the nginx configuration provided as attachment (nginx.conf to put
in <nginx dir>\conf\, overwriting the default one)
2. Place the test script in <nginx dir>\html\
3. Use the PHP configuration provided as attachement (php.ini to put in
<PHP dir>)
4. Modify Windows' routing table to force local traffic to make a round
trip to the nearest router/switch (local traffic can't be recorded on
modern Windows) :
5. In cmd.exe, type 'route add <computer external IP address> <gateway
IP address>' (you'll find required information with a quick 'ipconfig')
6. Start PHP with following arguments (either command-line or through a
shortcut): 'php-cgi.exe -b <computer external IP address>:9000'
7. Start nginx (simply double click on it)
8. Check that 2 nginx processes and 1 php-cgi.exe process exist in the
task manager.
9. Check (through 'netstat -abn') that php-cgi.exe is listening on
<computer external IP address>:9000
10. Start Wireshark recording on the interface related to the IP address
used before (or all interfaces) with capture filter 'port 9000'
11. Browse to http://localhost/test.php
12. Stop Wireshark recording

You'll find my recording of the backend traffic as attachement.
Please ignore the duplicated traffic (ad traffic going forth and back on
the network interface is recorded 2 times total: that's a drawback to the
'hack' setup you need on Windows to record local traffic...).

Hope that'll help

---
*B. R.*
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Attachments:
open | download - nginx.conf (2.7 KB)
open | download - test.php (77 bytes)
open | download - php.ini (67.3 KB)
open | download - nginx_php_backend.pcapng (5.5 KB)
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

Guests: 117
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready