5 Replies Latest reply on Oct 2, 2008 1:01 AM by jaikiran

    Virtual Hosts broken in JBoss 5?

    javidjamae

      I was trying to get virtual hosts to work in JBoss 5 Beta 4, but it doesn't seem to work.

      I have this host defined under my engine block in my server.xml:

       <Host name="somehostname.com" autoDeploy="false"
       deployOnStartup="false" deployXML="false">
       <Alias>www.somehostname.com</Alias>
       <Valve className="org.apache.catalina.valves.AccessLogValve"
       prefix="somehostname-com-" suffix=".log"
       pattern="common" directory="${jboss.server.home.dir}/log"/>
       </Host>
      


      I have this in my hosts file:

      127.0.0.1 somehostname.com
      


      I have the "useIPVHosts" attribute set to true on my connector as follows:

       <!-- A HTTP/1.1 Connector on port 8080 -->
       <Connector useIPVHosts="true" protocol="HTTP/1.1" port="8080" address="${jboss.bind.address}"
       connectionTimeout="20000" redirectPort="8443" />
      


      and I have the following in my jboss-web.xml file:

      <jboss-web>
       <virtual-host>somehostname.com</virtual-host>
      </jboss-web>
      


      The application seems to deploy, but I cannot access it using:

      http://somehostname.com:8080/hello/sayhello

      I verified that the same application deploys and works without a virtual host definition.

      I ran across this JIRA issue (http://jira.jboss.org/jira/browse/JBAS-3918). I couldn't make sense of Remy Maucherat's comment:


      This seems to work for me with the current AS 5. However, there's a change in behavior with the introduction of the mapVirtualHosts method that forces declaration of the vhosts in server.xml manually. Previously, vhosts mentioned in WEB-INF/jboss-web.xml would be automatically created.


      I'm not sure what he means by defining the vhost in the server.xml manually.

      I have three questions:
      1) Is the virtual hosts feature still broken in JBoss 5?
      2) Is there a work around?
      3) Is the useIPVHosts attribute necessary on the connector?

        • 1. Re: Virtual Hosts broken in JBoss 5?
          javidjamae

          I just tried this again on JBoss 5 CR1 and it still doesn't seem to work.

          Could somebody confirm if this is related to: https://jira.jboss.org/jira/browse/JBAS-3918

          Or am I just doing something wrong?

          • 2. Re: Virtual Hosts broken in JBoss 5?
            jfclere

            Have you declared your virtual host in server.xml

            • 3. Re: Virtual Hosts broken in JBoss 5?
              jaikiran

              FYI - I do have it working on JBoss-5 CR1.

              Javid,

              When you say, its not working, i guess you get a 404 error or something similar in the browser. Do the logs show something like:


              2008-09-08 13:22:17,151 DEBUG [org.jboss.web.tomcat.service.deployers.TomcatDeployment] (main) Initialized: {WebApplication: /D:/jboss-5.0.0.CR1/server/jaikiran/deploy/MyApp.war/, URL: vfsfile:/D:/jboss-5.0.0.CR1/server/jaikiran/deploy/MyApp.war/, classLoader: BaseClassLoader@18f1ef8{vfsfile:/D:/jboss-5.0.0.CR1/server/jaikiran/deploy/MyApp.war/}:26156792} jboss.web:j2eeType=WebModule,name=//myhost-jboss-5.com/MyApp,J2EEApplication=none,J2EEServer=none


              This log will confirm that the virtual host is being honoured.


              Here's my server.xml entry:
              <Host name="myhost-jboss-5.com" autoDeploy="false"
               deployOnStartup="false" deployXML="false">
               <Alias>www.myhost-jboss-5.com</Alias>
               <Valve className="org.apache.catalina.valves.AccessLogValve"
               prefix="myhost-com-" suffix=".log"
               pattern="common" directory="${jboss.server.home.dir}/log"/>
               </Host>



              jboss-web.xml:

              <jboss-web>
               <virtual-host>myhost-jboss-5.com</virtual-host>
              </jboss-web>



              The only difference between my setup and your's is the hosts file. I have this:

              127.0.0.1 localhost
              
              10.77.222.50 myhost-jboss-5.com
              


              I could not get it working with

              127.0.0.1 myhost-jboss-5.com


              So i decided to use the system IP to map the virtual host.

              One other thing, if you are having proxies setup, is to add myhost-jboss-5.com in firefox to bypass proxy.

              Finally, this is the URL which is used to access the application http://myhost-jboss-5.com:8080/MyApp/MyServlet



              • 4. Re: Virtual Hosts broken in JBoss 5?
                javidjamae

                Thanks for the suggestion.

                I tried this out on CR1 and CR2 but I still can't get it to work. I set up the hosts file to point to my IP address:

                127.0.0.1 localhost
                172.16.64.45 somehostname.com
                


                And, I verified that the virtual host is deployed:
                2008-09-23 19:44:49,015 DEBUG [org.jboss.web.tomcat.service.deployers.TomcatDepl
                oyment] (main) Initialized: {WebApplication: /C:/jboss-5.0.0.CR1/server/web/tmp/
                deploy/hello21878-exp.war/, URL: file:/C:/jboss-5.0.0.CR1/server/web/tmp/deploy/
                hello21878-exp.war/, classLoader: BaseClassLoader@100c858{vfszip:/C:/jboss-5.0.0
                .CR1/server/web/deploy/hello.war}:16828504} jboss.web:j2eeType=WebModule,name=//
                somehostname.com/hello,J2EEApplication=none,J2EEServer=none
                


                The interesting thing is that I'm not getting a 404 from Tomcat, but rather a "Failed to Connect" from Firefox. I can access a non-virtual host application fine using "localhost:8080" so I know I don't have a problem connecting to Tomcat on my machine. Any ideas?

                • 5. Re: Virtual Hosts broken in JBoss 5?
                  jaikiran

                   

                  "javidjamae" wrote:

                  The interesting thing is that I'm not getting a 404 from Tomcat, but rather a "Failed to Connect" from Firefox.


                  I guess its a setting in Firefox which is creating this issue. As i mentioned in my earlier reply:

                  "javidjamae" wrote:

                  One other thing, if you are having proxies setup, is to add myhost-jboss-5.com in firefox to bypass proxy.