# Nginx and php header + flush

**URL:** <https://www.ruby-forum.com/t/nginx-and-php-header-flush/211390>\
**Category:** NGINX\
**Created:** [September 2, 2011, 1:50pm UTC](https://www.ruby-forum.com/t/nginx-and-php-header-flush/211390 "2011-09-02T13:50:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [September 2, 2011, 1:50pm UTC](https://www.ruby-forum.com/t/nginx-and-php-header-flush/211390/1 "2011-09-02T13:50:59Z")

</div>

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 ?

Posted at Nginx Forum:

> **[nginx and php header + flush](https://forum.nginx.org/read.php?2,214654,214654#msg-214654)**
>
> 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();

---

<div class="post-metadata">

**Author:** ![ykse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b487fb/32.png) [@ykse](https://www.ruby-forum.com/u/ykse)\
**Post date:** [September 2, 2011, 1:57pm UTC](https://www.ruby-forum.com/t/nginx-and-php-header-flush/211390/2 "2011-09-02T13:57:49Z")

</div>

Hello!

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

> ?\>  
> 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] [twice chunked](http://mailman.nginx.org/pipermail/nginx/2011-August/028508.html)

Maxim D.

---

<div class="post-metadata">

**Author:** ![ykse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b487fb/32.png) [@ykse](https://www.ruby-forum.com/u/ykse)\
**Post date:** [September 2, 2011, 2:00pm UTC](https://www.ruby-forum.com/t/nginx-and-php-header-flush/211390/3 "2011-09-02T14:00:54Z")

</div>

Maxim, now it’s works fine!

Thanks a lot!

Posted at Nginx Forum:

> **[Re: nginx and php header + flush](https://forum.nginx.org/read.php?2,214654,214656#msg-214656)**
>
> 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();
