【发布时间】:2020-07-19 00:06:30
【问题描述】:
我们有一个使用以下技术的 Web 应用程序:Java、SpringBoot、Docker、微服务、Jhipster。 前端容器的端口号是 80。
我正在尝试禁用前端微服务的保持活动选项,因为 SSO 身份验证服务器要求将此参数设置为 false。
我尝试使用 maven 创建前端容器:mvn -Pqpm,no-liquibase -Dhttp.keepAlive=false clean verify jib:dockerBuild
我也尝试在前端容器的 pom.xml 中禁用:
<http.keepAlive>false</http.keepAlive>
<https.keepAlive>false</https.keepAlive>
但当我发送 http 请求时,keep-alive 选项仍然启用:
Connecting to qwerty.xyz|10.10.219.200|:80... connected.
HTTP request sent, awaiting response...
HTTP/1.1 200 OK
Date: Mon, 06 Apr 2020 21:14:50 GMT
Server: Apache
Last-Modified: Fri, 21 Oct 2016 08:42:15 GMT
ETag: "4107-84-53f5c04e1c7c0"
Accept-Ranges: bytes
Content-Length: 132
Cache-Control: max-age=0, no-store
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/html
Length: 132 [text/html]
Saving to: `/dev/null'
0K 100% 15.7M=0s
2020-04-06 23:14:50 (15.7 MB/s) - `/dev/null' saved [132/132]
我的 Springboot 配置:
<!-- Dependency versions -->
<jhipster-dependencies.version>3.0.1</jhipster-dependencies.version>
<!-- The spring-boot version should match the one managed by
https://mvnrepository.com/artifact/io.github.jhipster/jhipster-dependencies/${jhipster-dependencies.version} -->
<spring-boot.version>2.1.4.RELEASE</spring-boot.version>
你能帮我禁用它吗?
【问题讨论】:
-
您使用哪个http客户端发送请求?
-
你有没有尝试在你的 application.yml 中这样做?检查docs.spring.io/spring-boot/docs/current/reference/html/… 中的可用属性,因为Jhipster 默认使用Undertow,我会尝试
server.undertow.always-set-keep-alive。如果您在 Undertow 的文档中发现未作为应用程序属性公开的 Undertow 设置,您仍然可以通过代码设置它,请参阅github.com/spring-projects/spring-boot/issues/16077 -
嗨@GaëlMarziou,你写的参数是未知的。我使用的是旧版本的 Spring boot 吗?我在帖子中添加了我的配置。
-
是的,doc of Spring Boot 2.1.4 没有提到它,所以你可以将 Spring Boot 升级到 2.2.x,这并不难。否则,您可以使用 UndertowBuilderCustomizer 通过代码将 ALWAYS_SET_KEEP_ALIVE 设置为 false。
-
这不起作用。我认为它是由 jhipster 配置密钥管理的,但我没有找到它。当应用程序作为 jar 文件托管在 docker 映像中时,我不知道如何禁用此 http 配置。
标签: java spring-boot docker jhipster keep-alive