3

I just upgraded from django 1.2.4 to 1.3.

I'm using nginx in conjunction with fastcgi and for some reason every time when I access a page I get this error:

Unhandled Exception

An unhandled exception was thrown by the application.

Any ideas what the problem might be?

avatar
  • 12,087
  • 17
  • 66
  • 82
  • could you add a pastebin to your error.log, and maybe config files. – ashwoods May 11 '11 at 00:01
  • @ashwoods I found something in the /var/log/nginx/localhost.error_log: File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line 51, in load_middleware raise exceptions.ImproperlyConfigured('Middleware module "%s" does not define a "%s" class' % (mw_module, mw_classname)) ImproperlyConfigured: Middleware module "django.middleware.http" does not define a "SetRemoteAddrFromForwardedFor" class" while reading response header from upstream, client: 192.168.1.1, server: mysite.com, request: "GET /home/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:1234", host: "mysite.com" – avatar May 11 '11 at 18:41

2 Answers2

2

You need to track down your fastcgi error log. There should me more detailed information in there.

Matt Howell
  • 15,750
  • 7
  • 49
  • 56
  • I'm not sure if fastcgi has a error log but I looked under /var/log/nginx/error.log and didn't find anything. – avatar May 10 '11 at 19:18
1

To fix it I added this class (that practically doesn't do anything) in the : /usr/local/lib/python2.6/dist-packages/django/middleware/http.py

class SetRemoteAddrFromForwardedFor(object):
    """
    This middleware has been removed; see the Django 1.1 release notes for
    details.

    It previously set REMOTE_ADDR based on HTTP_X_FORWARDED_FOR. However, after
    investiagtion, it turns out this is impossible to do in a general manner:
    different proxies treat the X-Forwarded-For header differently. Thus, a
    built-in middleware can lead to application-level security problems, and so
    this was removed in Django 1.1

    """
    def __init__(self):
        import warnings
        warnings.warn("SetRemoteAddrFromForwardedFor has been removed. "
                      "See the Django 1.1 release notes for details.",
                      category=DeprecationWarning)
        raise MiddlewareNotUsed()
avatar
  • 12,087
  • 17
  • 66
  • 82