3

I've got a Django app running under Apache2 (linux) using mod_wsgi and file uploads fail when running in daemon mode but works when the python interpreter is embedded. Any idea what could be causing this and how I fix it?

The following Apache configuration is working:

<VirtualHost *:80>
  ServerName mysite.com
  DocumentRoot /var/www/

  Alias /media/ /var/www/media/

  <Directory /var/www/>
    Options -Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all

    Include /etc/apache2/yslow_optimizations.conf
  </Directory>

  WSGIScriptAlias / /var/djangoapp/apache/django.wsgi

  <Directory /var/djangoapp/apache/>
    Order allow,deny
    Allow from all
  </Directory>

  ErrorLog /var/log/apache2/mysite.error.log
  CustomLog /var/log/apache2/mysite.access.log combined
</VirtualHost>

But when I add the following directives to daemonize the wsgi process, the file upload instantly fails.

WSGIDaemonProcess mygroup display-name=%{GROUP} inactivity-timeout=600
WSGIProcessGroup mygroup

There doesn't appear to be anything in the Apache error log.

The Django form is using a FileField and just gives a "this field is required" error when doing the form.is_valid(). The view has a @login_required decorator. All of this is working fine when running in embedded mode.

Running as a daemon allows updating the code much more gracefully (by just touching the wsgi file) than when embedded which requires an Apache reload, so I'd much prefer that if it's possible.

Update: This occurs with Opera, not with FireFox.

Tom
  • 2,622
  • 1
  • 20
  • 12

1 Answers1

3

At a guess, you are not running latest mod_wsgi 2.X version and are using Opera browser.

There is a known issue with Opera and its use of HTTP 100-continue when using mod_wsgi daemon mode. This issue was fixed in mod_wsgi 2.4.

Since though you don't say what version of mod_wsgi you are using, nor which browser you are using, this is only a guess.

Graham Dumpleton
  • 5,990
  • 2
  • 20
  • 19
  • Sounds like it could have been a good guess. I'm using Opera, didn't occur to me that it could have been a browser issue. Looks like mod_wsgi 2.3, according to dpkg --list, from the ubuntu repository I guess. – Tom Sep 18 '09 at 03:08
  • Took a while until I could confirm by testing with FF, but you were right. Thanks. – Tom Sep 18 '09 at 23:41
  • I can confirm that this old friend also messes with Ajax requests (with ajax-uploader) in Firefox 10... and most likely would do the same in many other browsers. – benjaoming Feb 22 '12 at 11:49