Hello,

I have a file download problem with my Web2py application. The file is about 200kB.

web2py version: 1.99.2 (2011-09-26 06:55:33) stable
nginx-1.0.6
uwsgi-0.9.9.2
Debian Squeeze.

One of my crontroler creates a tar.gz file and returns it to the user. It works well with the default rocket server but not in my production environment. The file is corrupted, actually when a look at the file size it is never the expected size.

I have tested the two following return methods:
- return open(the_filename,'r+b').read()
- return response.stream(open('the_filename','r+b'))
with the same results.

I have the following Nginx configuration:

--------------------------------
user nginx;
worker_processes  4;

events {
    worker_connections  1024;
}

http {
    sendfile        on;
    client_max_body_size 100M;

    charset                 utf-8;
    default_type            application/octet-stream;
    ignore_invalid_headers  on;
    include                 mime.types;
    source_charset          utf-8;

    gzip on;
    gzip_vary         on;
    gzip_comp_level 2;
    gzip_proxied any;
gzip_types text/plain text/html text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

...

server {
        server_name  myserver.ens-lyon.fr;
        listen       443;

        ssl                  on;
        ...

        keepalive_timeout    70;

        access_log  /var/log/myserver_access.log;
        error_log /var/log/myserver_error.log;

        location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
          root /var/www/myserver/applications/;
          expires max;
        }
        location / {
            uwsgi_pass 127.0.0.1:9001;
            include uwsgi_params;
            uwsgi_param     UWSGI_SCHEME $scheme;
        }
        location /static {
          root /var/www/myserver/applications/init/;
          expires max;
        }
}
--------------------------------

I have googled the question, tried some Nginx configuration for file download problems without any success.

Could you help me?

Regards,

Thomas

Reply via email to