Only 64k sent when the first upstream failed in fastcgi_pass
Valentin V. Bartenev
vbart at nginx.com
Tue Jun 17 16:50:13 UTC 2014
On Tuesday 17 June 2014 23:50:19 Jing Ye wrote:
> Hello all,
>
> I have encountered the following possible bug in Nginx when using the
> fastcgi_pass directive to put a file larger than 64k. I’m not sure if this
> is a bug or I missed something in the config file.
>
> My nginx version is 1.5.12, and the problem remains when i switched to the
> newest 1.7.2.
>
>
> Here is my nginx.conf file,
>
> upstream *api.php.com <http://api.php.com>* {
> server 127.0.0.1:9902 max_fails=3 fail_timeout=30s;
> server 127.0.0.1:9901 max_fails=3 fail_timeout=30s;
> }
> server {
> listen 8080;
> server_name localhost;
> location ~ \.php$ {
> root html;
> fastcgi_pass *api.php.com <http://api.php.com>*;
> fastcgi_param SCRIPT_FILENAME
> /usr/local/nginx/html/$fastcgi_script_name;
> fastcgi_index index.php;
> include fastcgi_params;
> }
>
>
>
> And the index.php file,
>
> <?php
> /* simplify get the request body and print its length. */
> $raw_post_data = file_get_contents('php://input', 'r');
> print(strlen($raw_post_data));
> sleep(3); /* waiting for the server to be reset after 1
> second */
> ?>
>
>
[..]
>
> The response status is 200 OK, but only 65536 bytes(64k) received.
> Is this a bug or have i made something wrong in the config file?
> I’m really confusing and hope if someone could help me figure it out.
>
In the FastCGI protocol the data is transferred using "records". The maximum
size of one record is 64k. So you're probably getting only the first record
by calling file_get_contents() once.
wbr, Valentin V. Bartenev
More information about the nginx-devel
mailing list