2011-05-10 168 views
3

我剛剛從django 1.2.4升級到1.3。django - nginx + fastcgi - >未處理的異常(從Django 1.2.4升級到Django 1.3後)

我每次使用nginx的結合的FastCGI,由於某種原因,當我訪問一個頁面我得到這個錯誤:

Unhandled Exception 

An unhandled exception was thrown by the application. 

任何想法是什麼問題呢?

+0

你能不能一個引擎收錄添加到您的error.log中,也許配置文件。 – ashwoods 2011-05-11 00:01:41

+0

@ashwoods我在/var/log/nginx/localhost.error_log中找到了一些東西:文件「/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py」,第51行, (中間件模塊「%s」沒有定義「%s」類'%(mw_module,mw_classname)) 錯誤地配置:中間件模塊「django.middleware.http」沒有定義「SetRemoteAddrFromForwardedFor 「class」,同時讀取來自上游的響應頭,客戶端:192.168.1.1,server:mysite.com,請求:「GET/home/HTTP/1.1」,上游:「fastcgi://127.0.0.1:1234」 「mysite.com」 – avatar 2011-05-11 18:41:39

回答

1

要解決它,我加入這個類(即幾乎沒有做任何事情)在:/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() 
2

你需要找到你的fastcgi錯誤日誌。那裏應該有更詳細的信息。

+0

我不確定fastcgi是否有錯誤日誌,但是我查看了/var/log/nginx/error.log並沒有找到任何東西。 – avatar 2011-05-10 19:18:28