在https设置之后Django站点ERR_SSL_PROTOCOL_ERROR [英] django site ERR_SSL_PROTOCOL_ERROR after https setting

查看:64
本文介绍了在https设置之后Django站点ERR_SSL_PROTOCOL_ERROR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在尝试部署我的站点,基本上尝试

python manage.py check --deploy

按照它告诉我的去做:

WARNINGS:
?: (security.W004) You have not set a value for the SECURE_HSTS_SECONDS setting. If your entire site is served only over SSL, you may want to consider setting a value and enabling HTTP Strict Transport Security. Be sure to read the documentation first; enabling HSTS carelessly can cause serious, irreversible problems.
?: (security.W006) Your SECURE_CONTENT_TYPE_NOSNIFF setting is not set to True, so your pages will not be served with an 'x-content-type-options: nosniff' header. You should consider enabling this header to prevent the browser from identifying content types incorrectly.
?: (security.W007) Your SECURE_BROWSER_XSS_FILTER setting is not set to True, so your pages will not be served with an 'x-xss-protection: 1; mode=block' header. You should consider enabling this header to activate the browser's XSS filtering and help prevent XSS attacks.
?: (security.W008) Your SECURE_SSL_REDIRECT setting is not set to True. Unless your site should be available over both SSL and non-SSL connections, you may want to either set this setting True or configure a load balancer or reverse-proxy server to redirect all connections to HTTPS.
?: (security.W012) SESSION_COOKIE_SECURE is not set to True. Using a secure-only session cookie makes it more difficult for network traffic sniffers to hijack user sessions.
?: (security.W016) You have 'django.middleware.csrf.CsrfViewMiddleware' in your MIDDLEWARE, but you have not set CSRF_COOKIE_SECURE to True. Using a secure-only CSRF cookie makes it more difficult for network traffic sniffers to steal the CSRF token.
?: (security.W017) You have 'django.middleware.csrf.CsrfViewMiddleware' in your MIDDLEWARE, but you have not set CSRF_COOKIE_HTTPONLY to True. Using an HttpOnly CSRF cookie makes it more difficult for cross-site scripting attacks to steal the CSRF token.
?: (security.W018) You should not have DEBUG set to True in deployment.
?: (security.W019) You have 'django.middleware.clickjacking.XFrameOptionsMiddleware' in your MIDDLEWARE, but X_FRAME_OPTIONS is not set to 'DENY'. The default is 'SAMEORIGIN', but unless there is a good reason for your site to serve other parts of itself in a frame, you should change it to 'DENY'.
?: (security.W020) ALLOWED_HOSTS must not be empty in deployment.

基本上在settings.py中将所有这些设置为True,将Debug mode设置为False,然后将SECURE_HSTS_SECONDS=300

但是,在执行此操作之前,我忘记在服务器上设置我的站点,现在当我尝试访问它时,浏览器中显示以下错误:

Secure Connection Failed

An error occurred during a connection to 127.0.0.1:8001. SSL received a record that exceeded the maximum permissible length. Error code: SSL_ERROR_RX_RECORD_TOO_LONG

    The page you are trying to view cannot be shown because the authenticity of the received data could not be verified.
    Please contact the website owners to inform them of this problem.

和cmd:

[14/Sep/2016 17:40:46] code 400, message Bad request syntax ('x16x03x01x00|x01x00x00xx03x02xd3xb8S<	¿°xfd½U»ïäx98x99hxb9¥±T~x129x05áxc0V	x9axe3x82Ex00x00x10xc0	xc0x13xc0')
[14/Sep/2016 17:40:46] You're accessing the development server over HTTPS, but it only supports HTTP.

好的,它清楚地告诉我问题所在:我不支持https,但设置为支持它。但奇怪的是,即使在我删除了所有这些设置之后,站点仍然保持这种状态,我甚至无法使用debug=True在开发中访问它。

在执行此操作之前,我甚至尝试使用git恢复到该版本,但无济于事。相同的错误仍然存在。现在我真的很担心我会不会毁了它?请谁来帮帮我

推荐答案

您是否尝试过使用其他浏览器访问您的(开发人员)网站?可能是因为您在设置SECURE_HSTS_SECONDS上指定的值。如果这个值太高(比如31536000==1年),浏览器将继续访问您站点的https版本。

但是,您可以清除浏览器的HSTS设置。也许this可以提供帮助。

要更好地了解HSTS(如果这是问题所在),请阅读this文章。

让我知道这是否对您有帮助。

这篇关于在https设置之后Django站点ERR_SSL_PROTOCOL_ERROR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆