Spring Boot 管理混合内容并且不在服务器 https 中显示样式

问题描述 投票:0回答:2

我在服务器 https 中部署了我的应用程序 spring boot admin,但没有显示样式,在服务器 http 中部署时可以,但在 hhtps 中没有显示。

有没有办法在服务器https中显示页面? capture of spring boot admin in server https

spring spring-boot admin
2个回答
0
投票

如果您通过 https 收到默认登录页面,并且其中包含通过 http 收到的不安全内容,您将看到类似“混合内容:‘https://...’的页面是通过 HTTPS 加载的,但请求了不安全的内容”的消息。内容“http://...”。此请求已被阻止;内容必须通过 HTTPS 提供...”
我通过将 Content-Security-Policy 标头设置为“upgrade-insecure-requests”值来修复此问题。它指示浏览器处理站点的所有不安全 URL(通过 HTTP 提供的 URL),就好像它们已被替换为安全 URL(通过 HTTPS 提供的 URL)一样。 您可以在 Spring Boot 管理服务器应用程序的安全配置中这样做:

http.
    ...
    .and().headers().contentSecurityPolicy("upgrade-insecure-requests");

0
投票

我解决了这个问题,将其添加到我的 application.properties 中

spring.boot.admin.ui.public-url=https://your-sbadmin-url/admin
server.forward-headers-strategy=native
© www.soinside.com 2019 - 2024. All rights reserved.