2

I have converted a django site over from apache+wsgi to nginx+uwsgi. Everything seems to work properly except for file uploads using filebrowser. This did work with apache+wsgi, so I am assuming it is a configuration issue either in nginx or uwsgi.

The problem I am seeing is that the upload does not return an error, but the file is not written to disk.

The traffic is proxied by a frontend nginx instance to my nginx instance.

My nginx.conf

worker_processes  4;

events {
    worker_connections  1024;
}

http {
    access_log  /home/username/logs/user/access_nginx_uwsgi.log combined;
    error_log   /home/username/logs/user/error_nginx_uwsgi.log  crit;

    include mime.types;
    sendfile on;

    set_real_ip_from   127.0.0.1;
    real_ip_header     X-Forwarded-For;

    include /home/username/webserver/nginx/*.conf;

}

And my virtualhost configuration is.

server {
    listen 127.0.0.1:26293;
    server_name domainname.com;

    access_log  /home/username/logs/user/access_tdebt.log combined;
    error_log   /home/username/logs/user/error_tdebt.log  crit;

    location /static/ {
        alias /home/username/.virtualenvs/tdebt/tdebt/site_static/;
        expires 7d;
    }

    location /media/ {
        alias /home/username/.virtualenvs/tdebt/tdebt/site_media/;
        expires 7d;
    }
    location / {
        include uwsgi_params;
        uwsgi_pass unix:///home/username/webserver/sock/tdebt.sock;
    }
}

uwsgi config

[uwsgi]
chdir = /home/username/.virtualenvs/tdebt
home=/home/username/.virtualenvs/tdebt
wsgi-file = /home/username/.virtualenvs/tdebt/tdebt/webserver_config/wsgi.py
env = DJANGO_SETTINGS_MODULE=tdebt.settings
master = true
pidfile = /home/username/webserver/pid/tdebt.pid
socket = /home/username/webserver/sock/tdebt.sock
processes = 2
threads = 30
enable-threads = true
harakiri = 120
vacuum = true
reload-on-rss = 30
log-x-forwarded-for = true
idle = 300
procname-master = [username-tdebt] uWSGI Master
procname = [username-tdebt] uWSGI Worker
logto = /home/username/webserver/logs/tdebt_uwsgi.log
logdate = true

Any help is appreciated. If there is any other information that may help, please let me know.

UPDATE:

Issue seems to be with django-filebrowser and uwsgi as the problem can be replicated using Apache/mod_uwsgi.

UPDATE:

The issue was with the fork of django-filebrowser I was using. Does not work with uwsgi for some reason.

Himanshu
  • 31,810
  • 31
  • 111
  • 133
bmeyer71
  • 362
  • 3
  • 10
  • 23

1 Answers1

3

Nginx has a client_max_body_size directive which limits what size HTTP body can be sent. It's default is 1 meg so you should add client_max_body_size = 20m or something similar. You don't get an error because most browsers don't displace a 413 error

Community
  • 1
  • 1
Timmy O'Mahony
  • 53,000
  • 18
  • 155
  • 177
  • Thank you for the reply. I should have mentioned that the size of the file I am trying to upload is only about 14K so even the default 1MB should be enough for that. I will give this a try in any event. – bmeyer71 Nov 22 '12 at 16:46