2013-01-12 65 views
2

生產,我一直在試圖添加djangosecure.middleware.SecurityMiddleware(從http://pypi.python.org/pypi/django-secure)to我的設置,但還沒有任何運氣使其工作現場Django的:安全中間件崩潰

當我運行:

./manage.py checksecure 

一切都經過完美的罰款,但我無法加載網站上去它給了我下面的錯誤:。

The webpage has resulted in too many redirects. Clearing your cookies for this site or 
allowing third-party cookies may fix the problem. If not, it is possibly a server 
configuration issue and not a problem with your computer. 

本地,當我使用生產圖片在設置我收到一個頁面錯誤:

Unable to make a secure connection to the server. This may be a problem with the server, 
or it may be requiring a client authentication certificate that you don't have. 

我的終端然後被充滿奇怪的錯誤,我不能破譯:

[12/Jan/2013 14:15:25] code 400, message Bad HTTP/0.9 request type  
('\x16\x03\x01\x00\x98\x01\x00\x00\x94\x03\x02P\xf1\xc4]\x97e\xdd\xdc\xa9\xeb\x0e\xfc\xbb\xfa3 ') 
[12/Jan/2013 14:15:25] "??P??]?e?ܩ????3 Ʀ?-?:?.E:?o?FH?" 400 - 
[12/Jan/2013 14:15:25] code 400, message Bad request syntax  ('\x16\x03\x01\x00\x98\x01\x00\x00\x94\x03\x02P\xf1\xc4]M\xeeA50\xfc\x15%\xc1\xa4\x02\xec\xf0\x1fO') 
[12/Jan/2013 14:15:25] "??P??]M?A50?%????O" 400 - 
[12/Jan/2013 14:15:25] code 400, message Bad request syntax ('\x16\x03\x01\x00\x98\x01\x00\x00\x94\x03\x01P\xf1\xc4]\x8eg\xbey\x155\xafiP5\x85r\xb4|\x8c\x 

有什麼建議?

回答

3

無窮重定向意味着你已經設置SECURE_SSL_REDIRECTTrue,但在生產你的網站背後的SSL剝離代理服務器上運行,這樣的Django不能告訴該請求已經在事實上SSL,所以它會不停地嘗試重定向到SSL。如鏈接文檔中所述,您需要確定您的代理設置了哪些標頭以指示外部SSL請求,並相應地設置SECURE_PROXY_SSL_HEADER設置。

因爲Django的開發服務器不支持SSL,所以在本地使用生產設置將不起作用。奇怪的終端輸出是您的瀏覽器嘗試與不理解SSL的服務器進行SSL握手。

+0

感謝您的支持 –