简体   繁体   中英

Wildfly 8 : Not able to deploy Jolokia running at different port w.r.t other applications under same IP

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

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. 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>

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

It returns success.

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

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

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

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

The complete configuration can be found here .

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">

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM