BUG? Can not fully show the big size image.

Meng nginx-forum at nginx.us
Wed Jun 3 14:06:16 MSD 2009


Hi all,

I'm new to this community.
I did days of research to setup Nginx + PHP CGI + MySQL for a website. The problem is that client browser can not show the the full image of big size. When I refresh the browser, I can get random results of the image showing. Sometime get partial image showing, sometimes get full image showing. But small images(about 20k bytes) show perfectly. 
My platform is Intel quad cores CPU x 1, 4G memory, Intel Gigabyte NIC. CentOS 5.3 with latest updates. OS bundled PHP 5.1.6, Nginx 0.7.59 compiled from source.
The most strange thing is that the same website code works perfectly on another platform. This platform has 1 Celeron CPU(single core), 768M memory and 100M NIC. The software are Fedora 9, PHP 5.2.6, Nginx 0.7.59 compiled from source.
And moreover, same website code works on Apache + PHP + MySQL.
I did a lot of test on the Intel quad cores platform but get no result, such as
Try different web browser IE 6 and firefox 3,
Tried a lot of configuration for nginx.conf, php.ini.  Such as increases the buffer size.
Compiled and installed PHP 5.2.9
Compiled and installed kernel 2.6.28.10
...

My test code is



<?php
        header("Content-type: image/jpeg");
        readfile("images/untitled.jpg");
?>



This code does not work.

But html code like below works.



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



无标题文档

<!--
*{ margin:0px; padding:0px; border:0px;}
#main{ width:100%;}
-->













My nginx.conf is



user              apache apache;
worker_processes  4;

error_log         /var/log/nginx/error.log;
#error_log        /var/log/nginx/error.log  notice;
#error_log        /var/log/nginx/error.log  info;

pid               /var/run/nginx.pid;

events {
    use epoll;
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] $request '
                      '"$status" $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    connection_pool_size        256;
    client_header_buffer_size  1k;
    large_client_header_buffers  4  4k;
    client_max_body_size 10M;
    client_body_buffer_size 256k;

    access_log  /var/log/nginx/access.log  main;

    client_header_timeout  3m;
    client_body_timeout    3m;
    send_timeout           3m;

    sendfile        on;
    tcp_nopush     on;
    tcp_nodelay    off;
    server_names_hash_bucket_size 128;

    keepalive_timeout  65;

    gzip  on;
    gzip_min_length  1100;
    gzip_buffers     4  8k;
    gzip_types       text/plain application/javascript text/css text/xml;

    output_buffers   1  32k;
    postpone_output  1460;

    client_body_in_single_buffer on;
#???
#client_body_in_file_only clean;
  fastcgi_connect_timeout 300;
  fastcgi_send_timeout 300;
  fastcgi_read_timeout 300;
  fastcgi_buffer_size 64k;
  fastcgi_buffers 4 64k;
  fastcgi_busy_buffers_size 128k;
  fastcgi_temp_file_write_size 128k;

    # Load config files from the /etc/nginx/conf.d directory
    include /etc/nginx/conf.d/*.conf;

    #
    # The default server
    #
    server {
        listen       80;
#        server_name  _;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   /var/www/html;
            index  index.html index.htm;
        }

        error_page  404              /404.html;
        location = /404.html {
            root   /usr/share/nginx/html;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }

    }

        server {
                listen 80;
                server_name 192.168.0.30;
                access_log /var/log/nginx/access_30.log;
                error_log  /var/log/nginx/error_30.log;
                root    /var/www/html/ttl;
                location / {
                        index   index.php;
#If file not found, redirect to Zend handling, we can remove the (if) here and go directly rewrite
                        if (!-f $request_filename){
                                rewrite ^/(.+)$ /index.php?$1& last;
                                break;
                        }

                    #   limit_conn   one  1;
                        #limit_rate  200k;
                }

                location ~* ^.+.(js|ico|pdf|css|gif|jpg|jpeg|png)$ {
                        access_log off;
                        expires    1d;
                }

                location ~ \.php$ {
                    fastcgi_pass   127.0.0.1:9000;
#                    fastcgi_pass   unix:/tmp/phpcgi.sock;
                    fastcgi_index  index.php;
                    fastcgi_param  SCRIPT_FILENAME  /var/www/html/ttl$fastcgi_script_name;
                    include        fastcgi_params;
#                   fastcgi_pass_request_body off;
                }

        }

        server {
                listen 80;
                server_name z.f;
                access_log /var/log/nginx/access_zf.log;
                error_log  /var/log/nginx/error_zf.log;
                    root        /var/www/html/ttl;
                location / {
                        index   index.php;
#If file not found, redirect to Zend handling, we can remove the (if) here and go directly rewrite
                        if (!-f $request_filename){
                                rewrite ^/(.+)$ /index.php?$1& last;
                        }

                }
                location ~ \.php$ {
                    fastcgi_pass   127.0.0.1:9000;
#                    fastcgi_pass   unix:/tmp/phpcgi.sock;
                    fastcgi_index  index.php;
                    fastcgi_param  SCRIPT_FILENAME  /var/www/html/ttl$fastcgi_script_name;
                    include        fastcgi_params;
                }
        }
}



spawn php-cgi script:

/usr/local/bin/spawn-fcgi -u apache -g apache -f /usr/bin/php-cgi -a 127.0.0.1 -p 9000 -C 20 -- /usr/bin/php-cgi -c /etc

The screen shot of the problem is here:
http://www.eglx.com/J/bug.JPG


I also searched Google for the same problem reported, but got no resolution.  My problem seems very rare. Anyone has any ideas?
Thanks in advance!

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,2601,2601#msg-2601






More information about the nginx mailing list