本文介绍了无法将多个war包部署到不同的主机上,在Wildfly 8.1.0 Final上收听不同的端口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的用例涉及在单个Wildfly服务器上部署两个不同的包(war文件)。

My use case involves deployment of two different packages (war files) on a single Wildfly server.

standalone-full.xml 我的socket-binding-group在添加额外套接字后如下所示

In standalone-full.xml my socket-binding-group looks like this after addition of the extra socket as below

<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
    <socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
    <socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9993}"/>
    <socket-binding name="ajp" port="${jboss.ajp.port:8009}"/>
    <socket-binding name="http" port="${jboss.http.port:8080}"/>
    <socket-binding name="https" port="${jboss.https.port:8443}"/>
    <socket-binding name="jacorb" interface="unsecure" port="3528"/>
    <socket-binding name="jacorb-ssl" interface="unsecure" port="3529"/>
    <socket-binding name="messaging-group" port="0" multicast-address="${jboss.messaging.group.address:231.7.7.7}" multicast-port="${jboss.messaging.group.port:9876}"/>
    <socket-binding name="txn-recovery-environment" port="4712"/>
    <socket-binding name="txn-status-manager" port="4713"/>
    <socket-binding name="mylocal-internal" port="8099"/>
    <outbound-socket-binding name="mail-smtp">
        <remote-destination host="localhost" port="25"/>
    </outbound-socket-binding>
</socket-binding-group>

standalone-full.xml my添加外部服务器后子系统如下所示

In standalone-full.xml my Subsystem looks like this after addition of the external server as shown below

<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" alias="localhost">
                    <location name="/" handler="welcome-content"/>
                    <filter-ref name="server-header"/>
                    <filter-ref name="x-powered-by-header"/>
                    <single-sign-on path="/"/>
                </host>
            </server>
            <server name="mylocal-internal-server">
                <http-listener name="config-listener" socket-binding="mylocal-internal"/>
                <host name="mylocal-host" alias="localhost2">
                    <location name="/" handler="welcome-content"/>
                    <filter-ref name="server-header"/>
                    <filter-ref name="x-powered-by-header"/>
                    <single-sign-on path="/"/>
                </host>
            </server>
            <servlet-container name="default">
                <jsp-config/>
            </servlet-container>
            <handlers>
                <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
            </handlers>
            <filters>
                <response-header name="server-header" header-name="Server" header-value="WildFly/8"/>
                <response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
            </filters>
   </subsystem>

此外我的 jboss-web.xml myapp war的文件如下所示

Also my jboss-web.xml file for myapp war looks like the following

<?xml version="1.0" encoding="UTF-8"?>
<jboss-web xmlns="http://www.jboss.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="
      http://www.jboss.com/xml/ns/javaee
      http://www.jboss.org/j2ee/schema/jboss-web_8_0.xsd">
  <context-root>/myapp</context-root>
  <virtual-host>mylocal-host</virtual-host>
  <server-instance>mylocal-internal-server</server-instance>
</jboss-web>

当我通过管理控制台在9990上传和部署war文件时,所有内容都成功部署,但是当我尝试访问新端口8099上的myapp然后我收到404 Not Found错误。
我试图访问它,如

Everything deploys successfully when i upload and deploy the war file through admin console at 9990, but when i try accessing myapp on the new port 8099 then i am getting 404 Not Found error.I am trying to access it like http://mydomain:8099/myapp

但是,如果我为端口8080部署我的战争,那么它可以在

However if i deploy my war for port 8080 then it is available successfully at http://mydomain:8080/myapp

请就此提出建议。

推荐答案

从完成图片的评论中得到这个答案的一些历史记录。

A bit of history for this answer taken from the comments to complete the picture.


  • 此配置设置问题取自JBoss论坛中现有的异地问答,这清楚地表明设置没有什么问题;正确的配置到位,只需要在其中重新配置。

通过一些比较,可以发现的唯一区别是主机别名配置不同(localhost - > localhost2)。但是,上面JBoss论坛线程中的源材料没有配置用于生产部署,它是在localhost上进行开发的设置。这个问题是关于在适当的域名后面的生产中部署服务器。这就是找到缺失链接的地方。

With a little comparison, the only difference that could be spotted was that the host alias configuration was different (localhost -> localhost2). However the source material in the above JBoss forum thread is not configured for production deployment, it is a setup for development on the localhost. This question IS about deploying the server in production behind a proper domain name. So that's where the missing link is to be found.

正如此现有的相关stackoverflow问题所示,您需要在别名中输入正确的主机名才能生成这行得通。

As this existing related stackoverflow question indicates, you need to put the proper host name in the alias to make it work. Wildfly / Undertow : Multiple aliases for one host

这也是这个问题的最终解决方案;将域名添加到主机别名。

And that was ultimately the solution to this problem too; add the domain name to the host alias.

<host name="mylocal-host" alias="localhost2, my.domainname.com">
  ...
</host>

这篇关于无法将多个war包部署到不同的主机上,在Wildfly 8.1.0 Final上收听不同的端口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 23:10