WildFly:如何分隔Web应用程序?

时间:2019-02-13 09:45:12

标签: wildfly jboss-web

我在WildFly 15上有2个JEE应用程序的Web界面。它们都有不同的SSL证书。而且它们还具有不同的REST方法/ URL。而且客户端应该无法查看/访问其他相应方法。

通过添加其他HTTPS侦听器在不同端口上具有不同的SSL证书根本没有问题。但是现在,我正在为Web应用程序的分离而苦苦挣扎。

您可以通过在Web应用程序附带的jboss-web.xml中定义不同的虚拟主机来使用它们。但是您无法在WildFly配置中的虚拟主机上定义HTTP和HTTPS侦听器(在我的情况下,特别是在standalone-full.xml中)。您必须添加另一个(Web)服务器才能这样做。到目前为止也是如此。

因此,我在jboss-web.xml中定义了第二台(网络)服务器的虚拟主机。但是我无法部署Web应用程序,因为总是会收到一个WildFly找不到虚拟服务器的错误:

2019-02-12 15:06:07,930 ERROR [org.jboss.as.controller.management-operation] (External Management Request Threads -- 1) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "myapp-ear-1.0.4.ear")]) - failure description: {
    "WFLYCTL0412: Required services that are not installed:" => ["jboss.undertow.server.default-server.myapp-host"],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => [
        "jboss.deployment.subunit.\"myapp-ear-1.0.4.ear\".\"myapp-web-1.0.4.war\".undertow-deployment.UndertowDeploymentInfoService is missing [jboss.undertow.server.default-server.myapp-host]",
        "jboss.deployment.subunit.\"myapp-ear-1.0.4.ear\".\"myapp-web-1.0.4.war\".undertow-deployment is missing [jboss.undertow.server.default-server.myapp-host]"
    ]
}
2019-02-12 15:06:07,931 ERROR [org.jboss.as.server] (External Management Request Threads -- 1) WFLYSRV0021: Deploy of deployment "myapp-ear-1.0.4.ear" was rolled back with the following failure message: 
{
    "WFLYCTL0412: Required services that are not installed:" => ["jboss.undertow.server.default-server.myapp-host"],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => [
        "jboss.deployment.subunit.\"myapp-ear-1.0.4.ear\".\"myapp-web-1.0.4.war\".undertow-deployment.UndertowDeploymentInfoService is missing [jboss.undertow.server.default-server.myapp-host]",
        "jboss.deployment.subunit.\"myapp-ear-1.0.4.ear\".\"myapp-web-1.0.4.war\".undertow-deployment is missing [jboss.undertow.server.default-server.myapp-host]"
    ]
}

当然,“默认服务器” Web服务器中没有“ myapp-host”。它在“ myapp-server”中。但是我无法在jboss-web.xml中定义它:

<jboss-web>
    <virtual-host>myapp-host</virtual-host>
</jboss-web>

有人有什么主意吗?

编辑:

正如NikosParaskevopoulos所指出的:还有一个附加参数。因此整个内容(jboss-web.xml)应该看起来像这样:

<jboss-web>
    <server-instance>myapp-server</server-instance>
    <virtual-host>myapp-host</virtual-host>
</jboss-web>

我已经对其进行了测试,并且效果很好。谢谢NikosParaskevopoulos。

1 个答案:

答案 0 :(得分:0)

从JBoss / WildFly文档中,有一个<server-instance>元素:

  

[...]指定此应用程序属于哪个服务器实例配置

因此,将jboss-web.xml更改为:

<jboss-web>
    <virtual-host>myapp-host</virtual-host>
    <server-instance>myapp-server</server-instance>
</jboss-web>

顺便说一下,可以在docs / schema下的WildFly发行版中找到所有WildFly配置XML的XSD和DTD。它们包含足够的文档,我发现它们很有帮助。