2 Replies Latest reply on Jun 5, 2014 4:46 PM by Stephen Kay Branched to a new discussion.

    Undertow - 2 hosts / sockets serving same container

    Stephen Kay Newbie

      Hi,

       

      This is my use case :

       

      I would like to serve the same war deployed on standalone on 2 different ports, e.g. both localhost:8080 and 8081.

      Is it possible to tweak some handlers / whatever with Undertow to get this result ?

       

      Finally I would like to inject different http headers through the 2 different accesses with a different filter-ref.

      My understanding is that I need to define 2 different servers / default + a virtual server.

      But it seems that the war needs to know the target server / basically defined in jboss-web.xml

       

      So is it possible to define 2 different servers actually serving the same container ?

      how can I define the default-web-module in the virtual server configuration ?

       

      Thank you very much for any doc entry / help !

       

      BR

        • 1. Re: Undertow - 2 hosts / sockets serving same container
          Tomaz Cerar Master

          Stephen Kay wrote:

           

          I would like to serve the same war deployed on standalone on 2 different ports, e.g. both localhost:8080 and 8081.

          Is it possible to tweak some handlers / whatever with Undertow to get this result ?

          Simple, just add another http-listener with different socket binding for port 8081

           

          how can I define the default-web-module in the virtual server configuration ?

          host element has default-web-module attribute....

           

          example of full blown configuration we use for testing https://github.com/wildfly/wildfly/blob/master/undertow/src/test/resources/org/wildfly/extension/undertow/undertow-1.1.xml

           

          also take a look into subsystem's xsd schema you can find in docs/schema/ of your distro.

          or if you work via CLI take a look at http://wildscribe.github.io/Wildfly/8.0.0.Final/subsystem/undertow/index.html for model description.

           

          --

          tomaz

          1 of 1 people found this helpful
          • 2. Re: Undertow - 2 hosts / sockets serving same container
            Stephen Kay Newbie

            Thank you very much for sharing your work : you are anticipating solutions with a very good example of Undertow / should be referenced through official documentation !.

             

            According to your sample, this is what I added to standolone.xml  :

             

            <http-listener name="default2" socket-binding="http2" />

                            <host name="default-host2" alias="localhost2"  default-web-module="engine.war">

                                 <location name="/" handler="welcome-content"/>

                                <filter-ref name="server-header" />

                            </host>

                        </server>

            ...

            <socket-binding name="http2" port="8081" />

             

            The socket binding is OK : engine.war is accessed through 8080 and 8081 ; and second host configuration / default.web-module precision is unuseful for just this need

            BUT

            I'm still puzzled with the second host headers configuration.

            As you can see in my default-host2, I removed the

             

                                <filter-ref name="x-powered-by-header" />

             

            But I can see the header on both accesses : 8080 and 8081.

             

            If I remove that header on host name="default", this is impacting both accesses 8080 and 8081.

             

            The question is how / is it possible / to link the host filter-ref configuration to the socket-binding.

             

            BR