Welcome! Log In Create A New Profile

Advanced

Re: nginx and php header + flush

Maxim Dounin
September 02, 2011 07:58AM
Hello!

On Fri, Sep 02, 2011 at 07:50:32AM -0400, ykse wrote:

> Hello guys,
> I've got strange problem with my webserver. I've got nginx and apache
> with php as backend www server, and now when I tryin to run this code
> ->
>
> <?php
>
> header('HTTP/1.x 404 Not Found');
> echo "sometext";
> flush();
> ?>
>
> ( it's on apache )
>
> nginx returns something like this ->
>
>
> 8 sometext 0
>
>
> As you can see it's returns some numbers, but why ? When I'm openning
> same script directly from apache it's returns only "sometext" without
> any numbers.
>
>
> Do you have any idea why nginx returns this numbers ?

These numbers are from chunked encoding incorrectly sent by apache
to nginx. This behaviour is the result of a bug in apache's
mod_php which forces HTTP/1.1 reply despite the fact client
(nginx) uses HTTP/1.0 in request.

To fix this, just change

header('HTTP/1.1 ...');

to

header('HTTP/1.0 ...');

in your php code, or use "SetEnv downgrade-1.0" in apache config
as a workaround if changing code is problematic for some reason.
See [1] for more information.

[1] http://mailman.nginx.org/pipermail/nginx/2011-August/028508.html

Maxim Dounin

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

nginx and php header + flush

ykse September 02, 2011 07:50AM

Re: nginx and php header + flush

Maxim Dounin September 02, 2011 07:58AM

Re: nginx and php header + flush

ykse September 02, 2011 08:00AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 158
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready