2013-01-12 37 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

感谢您的支持 –