【发布时间】:2022-01-18 13:00:07
【问题描述】:
- 我有一个 Spring Boot 应用程序
- 我想启用 HSTS
我将记录在案的设置添加到我的 SecurityConfiguration(见下文), 但没有出现 HSTS 标头。
我做错了什么?
@Slf4j
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.headers()
.httpStrictTransportSecurity()
.includeSubDomains(true)
.preload(false)
.maxAgeInSeconds(31536000);
在访问页面或在官方网站https://gf.dev/hsts-test进行测试时,我在 Chrome 开发者工具(F12 -> Network -> Headers -> Response Header)中找不到标题
【问题讨论】:
-
你的后端使用
https吗? -
Spring Boot 应用程序在 http 8080 下运行,但 Dispatchserver 运行 https 将请求路由到 Spring Boot。我看到了http的问题。有没有办法告诉 Spring boot 在 http 的情况下也设置 HSTS Header?
标签: spring-boot spring-security hsts