django+nginx+uwsgi, filebrowser not uploading

By | December 7, 2017
Questions:

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.

Answers:

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

Leave a Reply

Your email address will not be published. Required fields are marked *