Bug 995411

Summary: Virtual Server cannot take "localhost" as alias more then once
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: ajustin <ajustin>
Component: WebAssignee: Rémy Maucherat <rmaucher>
Status: CLOSED NOTABUG QA Contact: Radim Hatlapatka <rhatlapa>
Severity: unspecified Docs Contact: Russell Dickenson <rdickens>
Priority: unspecified    
Version: 6.1.0CC: jclere, jdoyle, mvelas, tcerar
Target Milestone: ---   
Target Release: EAP 6.4.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-11-25 11:00:07 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description ajustin 2013-08-09 09:39:06 UTC
JBossWeb 7.2.0.Final

---

 <subsystem xmlns="urn:jboss:domain:web:1.4" default-virtual-server="default-host" native="false">
            <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http" redirect-port="8443"/>
            <connector name="http1" protocol="HTTP/1.1" scheme="http" socket-binding="http1" redirect-port="8443">
                <virtual-server name="vs1"/>
            </connector>

            <virtual-server name="default-host" enable-welcome-root="false">
                <alias name="localhost"/>
            </virtual-server>
            <virtual-server name="vs1">
                <alias name="localhost"/>
            </virtual-server>
        </subsystem>

...

        <socket-binding name="http" port="8080"/>
        <socket-binding name="http1" port="8180"/>


Goto "localhost:8180" --> results in 403.

Comment 1 Radim Hatlapatka 2013-08-09 10:31:04 UTC
I have tried it, and I am getting the same resutls as ajustin, but only if I have enable-welcome-root="true" otherwise I am getting for both cases 404

(In my case I used JBoss Web 7.2.1.Final).

Note; If you set the enable-welcome-root="true" via CLI and use only server reload, you start getting 200 responses with web content till you don't restart the EAP server, then it behaves the way as described by ajustin in Comment 0

Comment 2 Jean-frederic Clere 2013-08-23 10:22:13 UTC
-Dorg.apache.catalina.connector.USE_IP_PORT_FOR_ALIAS=true
and use Alias like the following:
            <virtual-server name="vs1">
                <alias name="localhost:8080"/>
            </virtual-server>
            <virtual-server name="vs2">
                <alias name="localhost:8180"/>
            </virtual-server>

Comment 3 Jean-frederic Clere 2013-08-23 15:53:49 UTC
Note the connector have to be associated to one virtual-host but the alias should cover all the hostname/port you want to limit to a connector.

Comment 4 Martin Velas 2014-07-31 13:22:23 UTC
For the latests bits EAP 6.3.0.ER10 the behaviour is the same as described by Radim in Comment 1.

Comment 5 Rémy Maucherat 2014-09-02 16:06:28 UTC
See comments from Jean-Frédéric. Even though a vhost can be "associated" with a connector, all the vhosts mapping is still done in a single place, so the name and aliases must be unique in the web container. Besides, it would also cause issues with internal mapping (ex: rewrite).

Comment 6 Radim Hatlapatka 2014-11-25 11:00:07 UTC
I have verified that proposed solution by Jean-Frederic works. I am closing this bug, if you have any objections be free and reopen it.

My configuration looks like this:
  <system-properties>
        <property name="org.apache.catalina.connector.USE_IP_PORT_FOR_ALIAS" value="true"/>
  </system-properties>
...

 <subsystem xmlns="urn:jboss:domain:web:2.2" default-virtual-server="default-host" native="false">
            <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http" redirect-port="8443"/>
            <connector name="http1" protocol="HTTP/1.1" scheme="http" socket-binding="http1" redirect-port="8443">
                <virtual-server name="vs2"/>
            </connector>

            <virtual-server name="default-host" enable-welcome-root="true">
                <alias name="localhost:8080"/>
            </virtual-server>
            <virtual-server name="vs2" enable-welcome-root="true">
              <alias name="localhost:8180"/>
            </virtual-server>
 </subsystem>
...
 <socket-binding name="http" port="8080"/>
 <socket-binding name="http1" port="8180"/>