https 设置后 django 站点 ERR_SSL_PROTOCOL_ERROR

2024-02-23

所以我正在尝试部署我的网站并且基本上尝试过

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 并将调试模式设置为 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 ('\x16\x03\x01\x00|\x01\x00\x00x\x03\x02\xd3\xb8S<\t¿°\xfd½U»ïä\x98\x99h\xb9¥±T~\x129\x05á\xc0V\t\x9a\xe3\x82E\x00\x00\x10\xc0\t\xc0\x13\xc0')
[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 https://docs.djangoproject.com/en/dev/ref/settings/#secure-hsts-seconds。如果这个值太高(比如 31536000 == 1 年),浏览器将继续点击https您网站的版本。

但是,您可以清除浏览器的 HSTS 设置。或许this https://really-simple-ssl.com/knowledge-base/clear-hsts-browser/可以帮助。

为了更好地理解 HSTS(如果这是问题)请阅读this https://www.chosenplaintext.ca/articles/why-hsts.html文章。

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

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

https 设置后 django 站点 ERR_SSL_PROTOCOL_ERROR 的相关文章

随机推荐

  • 什么时候可以不正常化? [关闭]

    就目前情况而言 这个问题不太适合我们的问答形式 我们希望答案得到事实 参考资料或专业知识的支持 但这个问题可能会引发辩论 争论 民意调查或扩展讨论 如果您觉得这个问题可以改进并可能重新开放 访问帮助中心 help reopen questi
  • 如何更改 c3 饼图中图例的文本

    如何更改饼图图例的文本 我在我的 php 页面中使用 c3 图表 我已经阅读了 c3 图表的文档 但没有运气 目前我正在使用这段代码 它显示图例true但我无法更改我尝试过的文本 var chart c3 generate bindto c
  • 了解域对象+数据映射器模式?

    我过去一直使用各种 ORM 并将所有逻辑放在模型中 无论其性质如何 SQL MongoDB 查询 甚至获取远程 JSON 对象 但是 当需要确保松散耦合以实现高水平的可测试性时 这种方法的问题很快就会出现 今天我读到了有关将模型分为两部分的
  • 为什么 css .hover div 会“闪烁”?

    我的网站上有一些 选项卡 包含文本 当鼠标悬停时 选项卡会展开并显示更多文本 出于我们的意图和目的 选项卡是某种菜单 但问题是 当鼠标悬停在上面时 选项卡会正确展开 因为悬停应该使它这样做 但然后很快 闪 回其原始大小 然后立即恢复到其悬停
  • TortoiseGit 到 Gitlab 存储库 HTTP 基本访问被拒绝

    自从 TortoiseGit 从 2 6 0 0 更新到 2 7 0 0 后 我无法再通过使用 TortoiseGit 访问我的 GitLab 我设法在 2 6 上获取 拉取和推送 但截至今天 在 2 7 上这不起作用 我有两台设置完全相同
  • 在 C# 事件处理程序中,为什么“sender”参数必须是对象?

    根据Microsoft 事件命名指南 https msdn microsoft com en us library h0eyck3s 28VS 71 29 aspx the senderC 事件处理程序中的参数 是always类型对象 即使
  • Wayland 上的屏幕截图显示为黑色

    我找到了这个code http ted mielczarek org code screenshot 在 Ted Mielczarek 网站上截取屏幕截图 gdk screenshot cpp Save a screenshot of th
  • 假“点击”来激活 onclick 方法

    我有一个元素onclick method 我想在另一个函数中激活该方法 或者 假装单击该元素 这可能吗 选择元素后 您可以调用 click document getElementById link click see https devel
  • apache 如何知道 SAML 响应已通过身份验证

    我是 Apache 和 SAML 的新手 我的 my app httpd conf 文件中有以下配置 它将未经身份验证的请求重定向到正常工作的 OKTA
  • 为什么此查询会在 Oracle 中产生 MERGE JOIN CARTESIAN?

    这是我的查询 select count from email prod junc j inner join trckd prod t5 on j trckd prod sk t5 trckd prod sk inner join prod
  • 如何在 Xamarin.Forms 中的网格中启用边框

    我正在 Xamarin Forms 中构建网格 我想添加像表格一样的边框 我以为可以在定义行和列时添加边框 但失败了 谁能帮我 这是我当前的代码 Grid grid new Grid VerticalOptions LayoutOption
  • 如何在 C# 中使用 FILE_ATTRIBUTE_TEMPORARY 创建文件?

    如何在 C 中使用 FILE ATTRIBUTE TEMPORARY 创建文件 所以将数据存储在Ram中但能够将其用作普通文件 我相信你必须使用 P Invoke 来调用本机CreateFile然后使用文件流 安全文件句柄 文件访问 htt
  • SQL Server 返回意外的周数

    我的表中有一些订单 2011 年的最后订单日期是 12 月 20 日 我使用 sql 命令来计算给定一周内的订单数 SELECT CONVERT VARCHAR 3 DATENAME week convert datetime order
  • ASP.NET 如何知道在回发期间触发哪个事件?

    在回发期间 EVENTTARGET表单变量保存name of the control发出回发 如果控件支持多个服务器端事件 ASP NET 如何知道要为该控件触发哪个事件 正如 Wiktor 提到的 ASP Net 中的许多控件已经为您以某
  • Inno Setup - 如何本地化组件和类型名称?

    如何本地化组件和类型名称 例如 Languages Name eng MessagesFile Idiomas English isl Name spa MessagesFile Idiomas Spanish isl 如果我选择英语 Ty
  • iOS CPU 配置文件:为什么这个线程会占用 99.9% 的 CPU?

    有时 当我加载表视图时 除了让表视图显示之外 我没有故意执行任何活动 我会等待几秒钟 然后 CPU 使用率就会飙升 我怎样才能找到原因 为什么这个线程会占用 99 9 的 CPU 我不知道 但这里有一些想法 负责的图书馆是UIKit 所以看
  • 暴露 Google Container Engine 中的两个端口

    是否可以在 Google 容器引擎中创建一个公开两个端口的 Pod 端口 8080 正在侦听传入内容 端口 80 将此内容分发给客户端 Google 给出了以下创建 Pod 的命令作为示例 kubectl run hello node im
  • JavaScript JSON 解析器告诉错误位置

    我在解析通过 WebSocket 接收的 JSON 时遇到了一些麻烦 原始问题 解析通过 WebSocket 接收到的 JSON 会导致错误 https stackoverflow com questions 7116035 parse j
  • 枚举类型的复选框列表 MVC Razor

    在我的 c net MVC 应用程序中 我想显示枚举类型的复选框列表 我有一个枚举类型 Flags public enum ModeType Undefined 0 Read 1 Edit 2 我的模型是 Public TrainingMo
  • https 设置后 django 站点 ERR_SSL_PROTOCOL_ERROR

    所以我正在尝试部署我的网站并且基本上尝试过 python manage py check deploy 并遵循它告诉我的一切 WARNINGS security W004 You have not set a value for the S