标签: undertow

WildFly - > Undertow - >将子域映射到war文件不起作用

WildFly 8.1.0最终Windows Server 2012 R2

我有两个子域指向此服务器,我希望每个子域的请求触发不同的war文件: -

webapp.domain1.com -> WildFly Server -> myapp1.war
test.domain2.net -> WildFly Server -> myapp2.war
Run Code Online (Sandbox Code Playgroud)

我的standalone.xml文件目前根据JBoss开发人员站点上收到的建议配置如下: -

<subsystem xmlns="urn:jboss:domain:undertow:1.1">
  <buffer-cache name="default"/>

  <server name="default-server">
    <http-listener name="default" socket-binding="http"/>

    <host name="default-host" default-web-module="myapp1.war" alias="webapp.domain1.com"/>
    <host name="other-host" default-web-module="myapp2.war" alias="test.domain2.net"/>
  </server>

  <servlet-container name="default">
    <jsp-config/>
  </servlet-container>

  <filters>
    <response-header name="server-header" header-value="WildFly/8" header-name="Server"/>
    <response-header name="x-powered-by-header" header-value="Undertow/1" header-name="X-Powered-By"/>
  </filters>
</subsystem>
Run Code Online (Sandbox Code Playgroud)

将浏览器指向webapp.domain1.com或test.domain2.net会导致请求按预期发送到WildFly服务器,但在这两种情况下都会触发相同的war文件(myapp1.war).

按如下方式切换<host ... />元素的'name'值会导致myapp2.war被调用,无论使用哪个URL: -

    <host name="other-host" default-web-module="myapp1.war" alias="webapp.domain1.com"/>
    <host name="default-host" default-web-module="myapp2.war" alias="test.domain2.net"/>
Run Code Online (Sandbox Code Playgroud)

看起来Undertow只处理"default-host"条目的细节.

这里有人可以帮忙吗?

如果不这样做,是否有人知道WildFly是否(以及如何)与Apache Web Server一起使用?

apache subdomain jboss wildfly undertow

5
推荐指数
1
解决办法
7225
查看次数

Wildfly / Undertow:一台主机的多个别名

单机/配置/独立-full.xml,我已经声明了以下主机,该作品

<host name="webhost" alias="gateway.example.com" />
Run Code Online (Sandbox Code Playgroud)

当我尝试添加另一个别名时,出现错误404。

<host name="webhost" alias="gateway.example.com www.gateway.example.com"/>
Run Code Online (Sandbox Code Playgroud)

文档称别名名单空格隔开。

virtualhost java-ee wildfly undertow

5
推荐指数
1
解决办法
2587
查看次数

实现行为类似于nginx的Undertow反向代理

出于开发目的,并不是每个人都可以在其计算机上安装nginx(例如Windows环境中的开发人员),但是我们希望能够做一个行为类似于nginx的反向代理。

这是我们非常具体的情况:

我们希望从http://0.0.0.0:8080提供这两种服务

所以我们想这样映射它:

这样,它的工作方式类似于带有URL重写反向代理的Nginx。

我签出了Undertow源代码和示例,甚至查看了这个特定示例:Reverse Proxy Example,但这是一个负载均衡器示例,但没有找到任何满足我需要的示例。

另外,我知道Undertow可以做到这一点,因为我们知道可以通过Undertow组件配置来配置WildFly来涵盖此特定情况,而不会出现问题,但是我们希望自己将其实现为本地开发的轻量级解决方案。

有人知道这样做的例子吗?或任何具有足够信息来实现此目的的文档?因为我也阅读了Undertow的有关反向代理的文档,但这对您毫无帮助。

谢谢

java spring reverse-proxy undertow

5
推荐指数
2
解决办法
2314
查看次数

Docker 容器中的 Spring Boot 响应时间太长

我需要在 Docker 容器中运行 HTTP REST API(带有嵌入式 Undertow 服务器的 Spring Boot 应用程序),但是当我运行容器并使用基准加载它时,我的响应时间太长(<1000ms),但是当我运行我的刚刚从 IDE 运行的应用程序我在(<10ms)内收到响应,为什么我有这么大的差异?我的泊坞窗文件:

FROM openjdk:8-jdk-alpine
ADD run.sh run.sh
RUN chmod +x run.sh
ADD tmp/data/data.zip tmp/data/data.zip
ADD travels-0.0.1-SNAPSHOT.jar app.jar
EXPOSE 80
CMD ["sh", "run.sh"]
Run Code Online (Sandbox Code Playgroud)

和 run.sh 从我运行应用程序的地方:

#!/bin/sh
echo "Unzipping data..."
mkdir -p /opt/
unzip -o /tmp/data/data.zip -d /opt/
echo "Starting server..."
java -Xmx3G -Xms3G -XX:+AggressiveOpts -server -Djava.security.egd=file:/dev/./urandom -jar app.jar --data.path=/opt/
Run Code Online (Sandbox Code Playgroud)

预先感谢您的帮助!

java docker spring-boot undertow

5
推荐指数
0
解决办法
2214
查看次数

java.lang.ClassNotFoundException:sun.misc.Cleaner

当使用Undertow 1.4.20(作为嵌入式Servlet引擎)时,在Java 9下运行我们的应用程序时会出现此异常.=: java.lang.ClassNotFoundException: sun.misc.Cleaner

原因是这一行io.undertow.server.DirectByteBufferDeallocator:

tmpCleanerClean = Class.forName("sun.misc.Cleaner").getMethod("clean");
Run Code Online (Sandbox Code Playgroud)

这个类确实不再存在于Java 9中.但可以使用替换: java.lang.ref.Cleaner

我现在可以忽略这个例外吗?是否有解决此问题的时间表(即使Java 9兼容)?

java undertow java-9

5
推荐指数
1
解决办法
1767
查看次数

Keycloak Redirect URI is adding port zero to the url

Encountered redirect_uri error in keycloak. Found same issue logged at JIRA KEYCLOAK-7237, just want to check any work around? Anyone can help? Thank you in advance.

2018-06-30 11:34:13,996 WARN [org.keycloak.events] (default task-8) type=LOGIN_ERROR, realmId=Victz, clientId=portal, userId=null, ipAddress=, error=invalid_redirect_uri, redirect_uri=https://www.example.com:0/home

I am using apache http reverse proxy running on centos7, wildly 10, keycloak 3.4.3. has also tried in below environment but same error.

Tried in wildly 10, wildly 11, jboss 7.1, Keycloak 3.4.3 as well as keycloak 4.0

Also …

reverse-proxy undertow keycloak wildfly-10 wildfly-11

5
推荐指数
2
解决办法
5664
查看次数

Springboot + undertow over SSL 100% CPU 使用率

我在几天前制作并投入生产的一个小网络应用程序中遇到了一些问题。当您访问应用程序并与其交互时,几分钟后就会立即崩溃(等待 SSL 握手的时间太长)。我使用 LetsEncrypt 证书。

问题似乎是 Undertow 在尝试使用SSLConduit.java类时阻塞了一些线程,这导致服务器的某些核心处于 100% 使用率。

服务器中的Java版本是:

openjdk version "11.0.2" 2018-10-16
OpenJDK Runtime Environment 18.9 (build 11.0.2+7)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+7, mixed mode)
Run Code Online (Sandbox Code Playgroud)

SpringBoot版本是:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.3.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
Run Code Online (Sandbox Code Playgroud)

application.properties 文件:

server.port=9002
server.ssl.key-store=keystore.jks
server.ssl.key-store-password=password
server.ssl.key-password=password
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://localhost:3306/example_db
spring.datasource.username=example_user
spring.datasource.password=password_db
Run Code Online (Sandbox Code Playgroud)

下流版本是:

在此输入图像描述

yourkit 正在告诉我们:

在此输入图像描述

在此输入图像描述 在此输入图像描述

我尝试放置另一个证书,但问题仍然存在。我不想更改为另一个网络服务器(但如果问题仍然存在,我会的)。有可能解决这个问题吗?或者我必须更改应用程序服务器?

编辑:github中的相关PR: https: //github.com/undertow-io/undertow/pull/721和JIRA中的问题:https://issues.jboss.org/browse/UNDERTOW-1493

java ssl spring-boot undertow

5
推荐指数
0
解决办法
1366
查看次数

Spring Boot Keycloak - 每个请求认证三次

我们将 Spring Boot 2.1.8 与 Undertow 一起使用,并使用 Keycloak 进行身份验证。每个请求都需要身份验证,但 servlet 在 Servlet 管道或过滤器中的不同点调用 Keycloak 进行身份验证三次。

我已经通过 Postman 在 Basic Auth 和 Bearer 令牌的日志中看到了这种行为。

关于为什么会发生这种情况的任何想法?它损害了我们的表现。

钥匙披风配置

@KeycloakConfiguration
public class KeycloakSecurityConfig extends KeycloakWebSecurityConfigurerAdapter {

    private static final String READ_WRITE = "WRITE_USER";
    private static final String READ = "READ_USER";

    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
        KeycloakAuthenticationProvider keycloakAuthenticationProvider = keycloakAuthenticationProvider();
        keycloakAuthenticationProvider.setGrantedAuthoritiesMapper(new SimpleAuthorityMapper());
        auth.authenticationProvider(keycloakAuthenticationProvider);
    }

    @Bean
    @Override
    protected SessionAuthenticationStrategy sessionAuthenticationStrategy() {
        return new RegisterSessionAuthenticationStrategy(new SessionRegistryImpl());
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception …
Run Code Online (Sandbox Code Playgroud)

java spring-boot undertow keycloak

5
推荐指数
1
解决办法
2000
查看次数

Undertow 按应用程序属性设置每个连接的最大并发请求数

我的主要目标是设置 Undertow 的最大并发请求连接限制。

我尝试通过属性进行配置来设置它。但这不起作用。

  • application.yml undertow:工作线程:1 io线程:1选项:服务器:MAX_CONCURRENT_REQUESTS_PER_CONNECTION:1

我研究了如何限制每个请求的最大连接数,并发现以下内容:

为了限制 undertow 中的连接,有必要实现 RequestLimitHandler 和 RequestLimit。

“Request Limiting Handler 限制并发请求数量的处理程序。如果数量超过限制,请求将排队。如果队列已满,则请求将被拒绝。”

http://undertow.io/undertow-docs/undertow-docs-1.2.0/#built-in-handlers
Run Code Online (Sandbox Code Playgroud)

我已经尝试了下一个实现,但此处理程序不会限制请求,因为它不会返回错误 503 响应,而且我无法与 MVC 方法绑定。

1. Test case: 
     @Bean
        public UndertowServletWebServerFactory myUndertowServletWebServerFactory() {
            final UndertowServletWebServerFactory factory = new UndertowServletWebServerFactory();

            final HandlerWrapper handlerWrapperLimit = new HandlerWrapper() {

                @Override
                public HttpHandler wrap(final HttpHandler handler) {
                    final int maximumConcurrentRequests = 1;
                    final int queueSize = 100;

                    final RequestLimit requestLimit = new RequestLimit(maximumConcurrentRequests,
                        queueSize);


                    final RequestLimitingHandler limitHandler = new RequestLimitingHandler(requestLimit,
                        new ResponseCodeHandler(
                            StatusCodes.OK));

                    return limitHandler; …
Run Code Online (Sandbox Code Playgroud)

java spring-boot undertow

5
推荐指数
0
解决办法
2489
查看次数

更新到wildfly 18后直接缓冲内存OutOfMemoryError

将环境从 更新到 后,Wildfly 13我们Wildfly 18.0.1经历了

A channel event listener threw an exception: java.lang.OutOfMemoryError: Direct buffer memory
at java.base/java.nio.Bits.reserveMemory(Bits.java:175)
at java.base/java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:118)
at java.base/java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:317)
at org.jboss.xnio@3.7.3.Final//org.xnio.BufferAllocator$2.allocate(BufferAllocator.java:57)
at org.jboss.xnio@3.7.3.Final//org.xnio.BufferAllocator$2.allocate(BufferAllocator.java:55)
at org.jboss.xnio@3.7.3.Final//org.xnio.ByteBufferSlicePool.allocateSlices(ByteBufferSlicePool.java:162)
at org.jboss.xnio@3.7.3.Final//org.xnio.ByteBufferSlicePool.allocate(ByteBufferSlicePool.java:149)
at io.undertow.core@2.0.27.Final//io.undertow.server.XnioByteBufferPool.allocate(XnioByteBufferPool.java:53)
at io.undertow.core@2.0.27.Final//io.undertow.server.protocol.http.HttpReadListener.handleEventWithNoRunningRequest(HttpReadListener.java:147)
at io.undertow.core@2.0.27.Final//io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:136)
at io.undertow.core@2.0.27.Final//io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:59)
at org.jboss.xnio@3.7.3.Final//org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
at org.jboss.xnio@3.7.3.Final//org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66)
at org.jboss.xnio.nio@3.7.3.Final//org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:89)
at org.jboss.xnio.nio@3.7.3.Final//org.xnio.nio.WorkerThread.run(WorkerThread.java:591)
Run Code Online (Sandbox Code Playgroud)

应用程序方面没有任何改变。我查看了缓冲池,似乎有些资源没有释放。我触发了几次手动 GC,但几乎什么也没发生。(正常运行时间2小时)

缓冲池稳步增长

之前在旧配置中它看起来像这样(正常运行时间> 250小时):

正确释放的缓冲池

现在我做了很多研究,我能找到的最接近的就是这篇关于 SO 的文章。然而,这是与 websockets 结合使用的,但没有使用websockets。我读了几篇(好)文章1、2、3、4、5、6 观看了有关主题视频我尝试了以下方法,但没有任何效果:

  1. OutOfMemoryError 发生在 5GB 处,因为堆是 5GB …

java out-of-memory wildfly undertow java-11

5
推荐指数
1
解决办法
4697
查看次数