[英]Facing 403 forbidden while accessing spring boot app on wildfly 26.0.1
[英]Wildfly with Spring Boot app: concurrent requests from SPA app result in 403
我们在 Wildfly 18 中部署了 Spring Boot 应用程序,通过耳中的战争(使用 SpringBootServletInitializer)。 耳中还存在其他战争,并且启用了 session 共享。 战争也共享一个安全领域。
从浏览器查询 Spring 引导应用程序 REST API 或 Z03D476861AFD3854510F2CB80C3FZ 工作正常。 当它是一个 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中尝试了许多配置,例如这是因为我们使用session共享,我希望每个session有多个请求:
<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 的任何帮助!
问题解决了:前面的应用程序,在耳边的战争中,不在安全域中。 并且默认安全域不是其他战争使用的安全域。
我们已经将前线战争放在同一个域中(通过 jboss-web.xml)并且......不再是 403。我们有点惊讶 403 不是在每次通话中,但我们很高兴它有效。
我认为您需要使用 SPA 托管服务器允许CORS 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.