Welcome! Log In Create A New Profile

Advanced

Only 64k sent when the first upstream failed in fastcgi_pass

Jing Ye
June 17, 2014 11:52AM
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 */
?>


We need two php-fpm servers listen on port 9901 and 9902, and importantly,
the server listen on 9902 should be somehow reset to make the upstream
module choose the next server listen on 9901. I made this by setting the
request_terminate_timeout argument to 1s.



Send a put request, test.png is a file sized 90833 bytes(>64K)

$ curl -T test.png *http://127.0.0.1:8080/index.php
http://127.0.0.1:8080/index.php* -v
* About to connect() to 127.0.0.1 port 8080 (#0)
* Trying 127.0.0.1...
* Adding handle: conn: 0x7fda7b803a00
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7fda7b803a00) send_pipe: 1, recv_pipe: 0
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> PUT /index.php HTTP/1.1
> User-Agent: curl/7.30.0
> Host: 127.0.0.1:8080
> Accept: */*
> Content-Length: 90833
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
* We are completely uploaded and fine
< HTTP/1.1 200 OK
* Server nginx/1.5.12 is not blacklisted
< Server: nginx/1.5.12
< Date: Tue, 17 Jun 2014 13:55:30 GMT
< Content-Type: text/html
< Transfer-Encoding: chunked
< Connection: keep-alive
< X-Powered-By: PHP/5.4.24
<
* Connection #0 to host 127.0.0.1 left intact
65536%


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.

Many thanks!
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Only 64k sent when the first upstream failed in fastcgi_pass

Jing Ye 1351 June 17, 2014 11:52AM

Re: Only 64k sent when the first upstream failed in fastcgi_pass

Valentin V. Bartenev 563 June 17, 2014 12:52PM

Re: Only 64k sent when the first upstream failed in fastcgi_pass

Jing Ye 581 June 17, 2014 09:48PM

Re: Only 64k sent when the first upstream failed in fastcgi_pass

Valentin V. Bartenev 1342 June 18, 2014 10:28AM

Re: Only 64k sent when the first upstream failed in fastcgi_pass

itpp2012 810 June 27, 2014 06:23AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 302
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