8 Replies Latest reply on Aug 17, 2005 2:24 AM by Mahesh Kudva

    Virtual Hosts - asked before, got no response

    Brian Newbie

      Hi all,

      I asked before but got no response to this question. I am trying to run multiple virtual hosts to my application one for each category, eg:


      I want these virtual hosts to map to a jsp for each one that correspond to:


      Is this possible?
      Please can someone help me on this
      thanks very much,

        • 2. Re: Virtual Hosts - asked before, got no response
          Brian Newbie

          Thanks for the reply Scott,
          but that doesn't really answer the question. I'm a long time user of jboss and I have deployed virtual hosting before where each virtual host points to a different war file. I have noted that as of 3.2.4 you can deploy one war to mulitple virtual hosts via the jboss-web.xml file, however what I want to know is - can you point each of these virtual hosts to a different jsp. Perhaps this can be done with the alias in tomcat, but I'm not sure. So can you for example have

          toys.mysite.com ---> goes to ---> www.mysite.com/toys.jsp

          This is not clear from the wiki which I quote below:

          "a single war can be deployed to mulitple virtual hosts through the jboss-web.xml virtual-host element. To make the jmx-console available on localhost, vhost1 and vhost2, edit the jmx-console.war/WEB-INF/jboss-web.xml

          <!-- Uncomment the security-domain to enable security. You will
          need to edit the htmladaptor login configuration to setup the
          login modules used to authentication users.

          Really appreciate any help you can give me,
          kind regards,

          • 3. Re: Virtual Hosts - asked before, got no response
            Anil Saldanha Master

            I have added this to the FAQ at the beginning of this forum section

            • 4. Re: Virtual Hosts - asked before, got no response
              Brian Newbie

              Thanks Anil,
              but really, that doesn't answer this question. I am not just asking about virtual hosts. I have used virtual hosts on jboss before, I have seen the wiki page before, I am asking a very specific virtual hosts question. Posting it on the faq looks as if this thread has been closed off with a link to the wiki as the answer. Unfortunately that has not answered the question.

              thanks anyway though,

              • 5. Re: Virtual Hosts - asked before, got no response
                Scott Stark Master

                This is url rewriting, not virtual hosting and is not supported by configuration alone. You need virtual hosting with a valve/filter.

                • 6. Re: Virtual Hosts - asked before, got no response
                  Brian Newbie

                  First of all Scott - thank you so much for pointing me in the right direction! I would be forever indebted if you could possibly explain what you mean when you say "is not supported by configuration alone. You need virtual hosting with a valve/filter"

                  Do you mean that it's not possible by using jboss-web.xml and editing the tomcat server.xml file?

                  I know that you can add elements to the tomcat server.xml element. Is this what you mean? Do you have any idea of what sort of a valve this would be? Any advice would be very much appreciated.


                  • 7. Re: Virtual Hosts - asked before, got no response
                    Mahesh Kudva Newbie

                    Hi Binario

                    I am also having the same problem. Can you let me know if you have any answers to this. In my case, the web apps are WAR files and I want to have the similar action.

                    http://test.com/library (Works perfectly)

                    http://library.test.com (never worked)

                    My DNS points to the correct IP where JBoss 4.0 is hosted.

                    I understand that I need to bind the WAR file to the virtual host and domain library.test.com.

                    But the question is how.

                    My server.xml:

                    <Host name="library"
                     autoDeploy="false" deployOnStartup="false" deployXML="false">

                    My WEB-INF/jboss-web.xml:

                    This is one set. I need to deploy at least 5 such WAR files.

                    Any ideas welcome.

                    Mahesh S Kudva

                    • 8. Re: Virtual Hosts - asked before, got no response
                      Mahesh Kudva Newbie

                      Thanks to all.

                      This setup has been tested on Apache2+JBoss+mod_jk-1.2.14_for MacOSX. And am sure it will work on other platforms as well. This setup also handles Apache related webapps..

                      Make the required entries in the DNS

                      webapp.war: Extract the war file using zip and rename the folder
                      with .war extension. Please put it in your deployment folder.

                      mod-jk.so: Obtain the modjk.so library file from www.apache.org and place then in the modules folder.

                      Apache-Virtual Host config

                      NameVirtualHost *.*.*.*:80
                      <VirtualHost *.*.*.*:80>
                       ServerName webapp.robosoft.co.in
                       ServerAlias www.webapp.robosoft.co.in
                       ServerAdmin root@localhost
                       DocumentRoot /Volumes/Extra/jboss/server/default/deploy/webapp.war
                       JkMount /* loadbalancer
                       DirectoryIndex index.html index.jsp
                       ErrorLog logs/webapp-error_log
                       CustomLog logs/webapp-access_log common

                      LoadModule jk_module /opt/apache2/modules/mod_jk.so
                      JkWorkersFile /opt/apache2/conf/workers.properties
                      JkLogFile /opt/apache2/logs/mod_jk.log
                      JkLogLevel info
                      JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
                      JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
                      JkRequestLogFormat "%w %V %T"
                      JkMount /webapp.domain.com/*.jsp loadbalancer
                      JkMountFile /opt/apache2/conf/uriworkermap.properties
                      JkShmFile /opt/apache2/logs/jk.shm
                      <Location /jkstatus/>
                       JkMount status
                       Allow from all


                      <Host name="webapp.domain.com" debug="0" appBase="deploy"
                       <Logger className="org.apache.catalina.logger.FileLogger"
                       directory="logs" prefix="webapp_log1." suffix=".log"
                       <Context path=""
                      docBase="${jboss.server.home.dir}/deploy/webapp.war" debug="0"



                      Regards & Thanks
                      Mahesh S Kudva
                      Network Analyst
                      Robosoft Technologies