1 Reply Latest reply on May 4, 2010 5:37 AM by jaikiran pai

    5.1.0GA - change https port from 8443 (or http from 8080), and no, binding sets are not the answer

    Florian Weps Newbie

      Hi. First post. Sorry if this is a recurring question. I certainly tried to read the manuals. Such as there are.

       

      My task: run a JBoss-5.1.0GA on port 8010 with ssl enabled. (Don't ask).

       

      Anyway what I found out is:

       

      This is not configured in deploy/jbossweb.sar/server.xml. That's not where you configure ports, even though it looks like they should be. Because this file is passed through some awesome XSLT transformation to cater for something called a "binding set". Which is a nice concept, if sparsely documented. I get it, finally.

       

      These binding sets even offer the admin a way to override the "add 100 to every port" thing. But: 8080 can't be changed in bindingservice.beans/META-INF/bindings-jboss-beans.xml by adding a fixed port override in a binding set bean. It looks like it should be, but it isn't, because the XSLT actually overrides this override (in red).

       

      <!-- The ports-01 bindings are obtained by taking the base bindings and adding 100 to each port value -->
         <bean name="Ports01Bindings">
            <constructor>
               <!--  The name of the set -->
               <parameter>ports-01</parameter>
               <!-- Default host name -->
               <parameter>${jboss.bind.address}</parameter>
               <!-- The port offset -->
               <parameter>100</parameter>
               <!-- Set of bindings to which the "offset by X" approach can't be applied -->
               <parameter>
                 <set elementClass="org.jboss.services.binding.ServiceBindingMetadata">
                   <bean>
                     <property name="serviceName">jboss.web:service=WebServer</property>
                     <property name="port">8010</property>
                     <property name="description">JBoss Web HTTP connector socket; also drives the values for the HTTPS and AJP sockets</property>
                     <property name="fixedPort">true</property>
                  </bean>
                </set>
              </parameter>

            </constructor>
         </bean>

       

      This does't work. And it doesn't work for https either, because the XSLT overrides the overrides there, too!

       

      What does work, is modifying the XSLT (to be found in the same config file) to force the port (my changes in red, the affected line in blue).

       

      <!-- XSL Transform to apply to server.xml -->
         <bean name="JBossWebConnectorXSLTConfig"
              >

       

            <constructor>
                <parameter><![CDATA[
         <xsl:stylesheet
               xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>

       

           <xsl:output method="xml" />
           <xsl:param name="port"/>

       

           <xsl:variable name="portAJP" select="$port - 71"/>
           <xsl:variable name="portHttpsOrig" select="$port + 363"/>
          <xsl:variable name="portHttps" select="8010"/>

       

           <xsl:template match="/">
             <xsl:apply-templates/>
           </xsl:template>

       

            <xsl:template match = "Connector">
               <Connector>
                  <xsl:for-each select="@*">
                  <xsl:choose>
                     <xsl:when test="(name() = 'port' and . = '8080')">
                        <xsl:attribute name="port"><xsl:value-of select="$port" /></xsl:attribute>
                     </xsl:when>
                     <xsl:when test="(name() = 'port' and . = '8009')">
                        <xsl:attribute name="port"><xsl:value-of select="$portAJP" /></xsl:attribute>
                     </xsl:when>
                     <xsl:when test="(name() = 'redirectPort')">
                        <xsl:attribute name="redirectPort"><xsl:value-of select="$portHttps" /></xsl:attribute>
                     </xsl:when>
                     <xsl:when test="(name() = 'port' and . = '8443')">
                        <xsl:attribute name="port"><xsl:value-of select="$portHttps" /></xsl:attribute>
                     </xsl:when>
                     <xsl:otherwise>
                        <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>
                     </xsl:otherwise>
                  </xsl:choose>
                  </xsl:for-each>
                  <xsl:apply-templates/>
               </Connector>
            </xsl:template>

       

           <xsl:template match="*|@*">
             <xsl:copy>
               <xsl:apply-templates select="@*|node()"/>
             </xsl:copy>
           </xsl:template>
         </xsl:stylesheet>
         ]]>
                </parameter>
            </constructor>
         </bean>

       

      But I keep thinking there *must* be a nicer way, one that doesn't involve hacking the XSLT.


      I'd like to do it the Right Way. If there is one.

       

      Hints?

       

      Cheers,

      Florian