Wildfly 8:无法部署在相同IP下的其他应用程序在其他端口上运行的Jolokia [英] Wildfly 8 : Not able to deploy Jolokia running at different port w.r.t other applications under same IP

查看:186
本文介绍了Wildfly 8:无法部署在相同IP下的其他应用程序在其他端口上运行的Jolokia的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先要解决的不是Jolokia问题,而是与Wildfly有关的问题.

To start with this not a Jolokia issue, but something related to Wildfly.

我希望我的wildfly中的一个应用程序(Jolokia)侦听与其余应用程序不同的端口(在默认端口侦听).在这两个之后(此处

I want one of my applications (Jolokia) in wildfly to listen to a different port from the rest of the applications (listening at default port). Following these two (here and here), I have done the following : 1. Added jboss-web.xml under WEB-INF directory for the jolokia war (in addition to the web.xml located at the same location) :

<?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>/jolokia</context-root>
        <virtual-host>jolokia-host</virtual-host>
        <server-instance>jolokia-server</server-instance>
 </jboss-web>

  1. 在standalone.xml中添加了以下内容(jolokia服务器).我只想访问本地主机上的两个应用程序(没有其他域).

  1. Added the following (jolokia-server) in standalone.xml. I want to access both the applications at localhost only (no different domain).

<subsystem xmlns="urn:jboss:domain:undertow:1.2">
    <buffer-cache name="default"/>
    <server name="default-server">
        <http-listener name="default" socket-binding="http"/>
        <https-listener name="secure" socket-binding="https" security-realm="ssl-realm"/>
        <host name="default-host" alias="localhost">
            <location name="/" handler="welcome-content"/>
            <filter-ref name="server-header"/>
            <filter-ref name="x-powered-by-header"/>
        </host>
    </server>
    <server name="jolokia-server">
        <http-listener name="jolokia-listener" socket-binding="jolokia-manager"/>
        <host name="jolokia-host" alias="localhost">
            <location name="/" handler="welcome-content"/>
            <filter-ref name="server-header"/>
            <filter-ref name="x-powered-by-header"/>
        </host>
    </server>
    <servlet-container name="default">
        <jsp-config/>
        <websockets/>
    </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>

......

<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="jolokia-manager" port="8282"/>
    <outbound-socket-binding name="mail-smtp">
        <remote-destination host="localhost" port="25"/>
    </outbound-socket-binding>
</socket-binding-group>

有了这些,wildfly(和应用程序Jolokia)就开始在8282侦听.但是,我只能通过本地主机从同一盒子访问Jolokia应用程序:

With these, wildfly (and the application Jolokia) starts listening at 8282. However, I can access Jolokia application only from the same box through localhost :

curl -u admin:admin http://localhost:8282/jolokia

它返回成功.

curl -u admin:admin http://10.104.245.67:8282/jolokia
<html><head><title>Error</title></head><body>404 - Not Found</body></html>

但是,其他应用程序正在侦听默认端口(在我们的示例中为8778),并且本地主机和真实IP(10.104.245.67)都可用.两个端口都连接到0.0.0.0.

However, the other applications are listening at the default port (in our case 8778) and available with both localhost as well as real IP (10.104.245.67). Both the ports are attached to 0.0.0.0.

#netstat -an | grep 8282
tcp        0      0 0.0.0.0:8282                0.0.0.0:*                   LISTEN

#netstat -an | grep 8778
tcp        0      0 0.0.0.0:8778                0.0.0.0:*                   LISTEN

**更新:** 正如ctomc所指出的,在虚拟服务器中添加默认主机"可以解决该问题.

**Update : ** As pointed out by ctomc, adding "default-host" to the virtual server solved the issue.

<server name="jolokia-server" default-host="jolokia-host">

完整配置可在此处找到.

推荐答案

您缺少名为"jolokia-server"的服务器的默认主机配置

you are missing default-host configuration for server named "jolokia-server"

这就是为什么它仅响应本地主机"名称的原因.

that is why it only responds to "localhost" name.

解决此问题的最简单方法是像这样修改您的配置:

easiest way to solve this is to modify your config like this:

<server name="jolokia-server" default-host="jolokia-host">

即使没有虚拟主机映射(别名),这也会使jolokia-host成为默认主机

this will make jolokia-host default host even when there is no vhost mapping (alias)

这篇关于Wildfly 8:无法部署在相同IP下的其他应用程序在其他端口上运行的Jolokia的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆