无法在邮递员的 HEADERS 响应中看到 strict-transport-security 参数?

Unable to see strict-transport-security parameter in HEADERS response in postman?

我正在尝试使用 scala 代码在 play 框架类型安全服务器中实现 HSTS。

我已经用下面一行更新了 application.config 文件:

 play.filters.enabled += "play.filters.headers.SecurityHeadersFilter"
 play.filters.headers.frameOptions = "DENY"
 play.filters.https.strictTransportSecurity="max-age=31536000;includeSubDomains; preload"

因此,在我执行 URL 时添加此内容后:https://www.mywebsite.com 在 postman 中,在 headers 列中我希望看到:

 content-length: 85
 content-type: text/html; charset=utf-8
 request-time: 2
 x-frame-options: DENY
 strict-transport-security: max-age=15552000; preload

这些内容长度、类型和时间已经来了,但是这些严格的传输参数没有反映在 headers 响应中 postman post 配置文件中的代码更改.

除了上面的代码行,我什至在 app.config:

中添加了这行代码
    https {
     strictTransportSecurity = "max-age=31536000; includeSubDomains"
     redirectStatusCode = 308
      }

但是这些更改对响应标头也没有影响。

简而言之,如果我在 git bash 中为我的站点使用 curl,我将看到与我在 Facebook 中看到的类似的结果:

 curl --head https://www.facebook.com
 x-frame-options: DENY
 strict-transport-security: max-age=15552000; preload
 x-content-type-options: nosniff

当我输入 https://www.mywebsite.com 时,我的 URL 也是如此 我需要查看:

     strict-transport-security: max-age=15552000; preload

在 headers 回复栏中,但我没有看到这个。

任何人都可以指出我哪里出了问题。我是 HSTS 和 Scala 以及安全任务的新手。

我试图在 App.config 文件中添加

  play.filters.enabled += "play.filters.https.RedirectHttpsFilter"
  play.filters.https.redirectEnabled = true
  play.filters.enabled += "play.filters.headers.SecurityHeadersFilter"
  play.http.forwarded.trustedProxies=["0.0.0.0/0", "::/0"]
  play.filters.https.strictTransportSecurity = "max-age=31536000; 
  includeSubDomains; preload"
  play.filters.https.redirectStatusCode = 301

但没有进入 headers 响应。我还应该在哪里更改 playframework 中的代码以在 headers.

中显示它

我不知道 Scala 或 playframework,但从快速 Google 来看,我觉得 strictTransportSecurity 不属于 SecurityHeadersFilter, but part of RedirectHttpsFilter

所以你需要包括这个过滤器吗?

play.filters.enabled += play.filters.https.RedirectHttpsFilter

还要注意这条评论:

By default, the redirect only happens in Prod mode. To override this, set

play.filters.https.redirectEnabled = true.

请注意,如果您对纯文本 HTTP 有任何需求,HSTS 可能会破坏您的站点 - 例如,您尚未移动到 HTTPS 的子域(例如 blog.example.com),或使用相同域的内部站点( intranet.example.com)。请先将其设置为 LOW max-age 并在证明它不是引起和问题时建立它,请 不要 使用includeSubDomains 一开始,真的,真的 包括 preload 直到你准备好了(我个人认为很少有网站应该设置这个)。我有 blogged about the dangers of switching these on when people do not fully understand these 并且,如果你只是为了打开它们而苦苦挣扎,那么我肯定会暂时把你算在那个营地里!