【发布时间】:2020-10-23 14:30:57
【问题描述】:
我们在 Wildfly 18 中部署了一个 Spring Boot 应用程序,通过耳中的战争(使用 SpringBootServletInitializer)。耳中还存在其他战争,并且启用了会话共享。战争还共享一个安全域。
从浏览器或邮递员查询 Spring Boot 应用程序 REST API 工作正常。当它是一个 SPA 应用程序时,它会失败:并发请求会收到 403 Forbidden,例如在访问日志中:
127.0.0.1 [02/Jul/2020:22:54:46 +0200] "GET /api/Foo?bar=1 HTTP/1.1" 403 "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36"
序列化 SPA 请求使其再次工作,但这只是为了测试目的:我们希望来自 SPA 的并发请求!
我在standalone.xml 中尝试了许多配置,例如这是因为我们使用会话共享并且我希望每个会话一次有多个请求:
<subsystem xmlns="urn:jboss:domain:infinispan:9.0">
<cache-container name="web" default-cache="passivation" module="org.wildfly.clustering.web.infinispan">
<local-cache name="passivation">
<locking isolation="NONE"/>
<transaction mode="BATCH"/>
<file-store passivation="true" purge="false"/>
</local-cache>
<local-cache name="persistent">
<transaction mode="BATCH"/>
<file-store passivation="false" purge="false"/>
</local-cache>
</cache-container>
或者这个允许并发请求:
<subsystem xmlns="urn:jboss:domain:undertow:10.0" statistics-enabled="true">
<buffer-cache name="default"/>
<server name="default-server">
<http-listener name="default" max-connections="100" socket-binding="http" max-parameters="5000" allow-unescaped-characters-in-url="true"/>
<host name="default-host" alias="localhost">
<access-log pattern="%h %t "%r" %s "%{i,User-Agent}"" use-server-log="false"/>
<filter-ref name="x-frame-options"/>
<filter-ref name="limit-connections"/>
</host>
</server>
<servlet-container name="default" default-encoding="UTF-8" max-sessions="10000">
<jsp-config/>
<session-cookie http-only="true"/>
</servlet-container>
<filters>
<request-limit name="limit-connections" max-concurrent-requests="3000" queue-size="100"/>
<response-header name="x-frame-options" header-name="X-Frame-Options" header-value="SAMEORIGIN"/>
</filters>
</subsystem>
欢迎在并发请求上摆脱这些讨厌的 403 的任何帮助!
【问题讨论】:
标签: java spring-boot wildfly undertow