ruby-on-rails - 如何验证 HSTS 在 Rails 应用程序中是否按预期工作?
问题描述
大多数文档都讨论了添加 config.force_ssl = true ,它为 Rails 应用程序提供 HSTS。那么,我怎样才能确保它按预期工作?如何测试为每个请求添加的 HSTS 标头?任何帮助深表感谢。
解决方案
使用curl -I https://your_website.domain
或浏览器开发工具查看响应标头。您对Strict-Transport-Security
标题感兴趣:
curl -I https://www.ssllabs.com/
HTTP/2 200
date: Fri, 23 Apr 2021 15:25:17 GMT
server: Apache
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
strict-transport-security: max-age=31536000 <-- this one
cache-control: no-cache, no-store, max-age=0, must-revalidate
pragma: no-cache
expires: 0
x-frame-options: DENY
content-type: text/html;charset=ISO-8859-1
content-language: en-US
content-length: 6587
set-cookie: ...
content-security-policy: ...
推荐阅读
- latex - 如何将特定小节中的文本更改为斜体?
- javascript - 从 setTimeout 调用 setState 会导致文本字段光标意外跳转
- java - 强制 ServerSocket 使用 IPv4
- excel - Excel VBA - 在标记为 3 个字符长度的工作表中过滤
- dotnetnuke - DNN 注册链接未显示
- node.js - 如何仅使用 Apollo Server 2 graphql 端点的快速中间件
- html - CSS - 当 HTML 元素包含另一个特定类时定位伪元素
- typescript - 打字稿编译器错误地假设错误值
- sensenet - 在本地主机上安装 Sensenet
- spring-boot - Flux 响应而不是 WebSocket (Spring boot)