4 Replies Latest reply on Aug 17, 2005 2:22 AM by maheshkudva

    Mapping vitual servers to .war files

    stiphout

      Hi all --

      Ok, so I have an ISP that's set up to give me three domains on one IP. Apache has virtual hosts set up for each of them in the httpd.conf file, and I have a .war for each of them, ready to go.

      For instance, domain1.com has domain1.war, domain2.com has domain2.war, etc.

      Problem is, best I can tell, the only way to get the sort of "default application" behavior that I want is to end up with URLs that look like this:

      http://www.domain1.name/domain1/index.jsp

      When I'd much prefer to have Jboss somehow say, "hey, this is domain1, so use the domain1.war for it."

      I've tried to find this setting, but I've struck out. Am I missing something, or is there a fundamentally better way to architect these sites on this virtual host setup?

      Thanks!!!
      -Dutch

        • 1. Re: Mapping vitual servers to .war files
          jiwils

          It may be that the Apache module mod_jk2 is just what you are looking for. It provides smart connectivity/routing from Apache HTTPD to Tomcat instances.

          There is a Wiki page describing how to install mod_jk2 into Apache HTTPD and how to configure it here:

          http://www.jboss.org/wiki/Wiki.jsp?page=UsingMod_jkWithJBoss

          For more information, you can also consult the documentation/help pages on the mod_jk2 web site here:

          http://archive.apache.org/dist/jakarta/tomcat-connectors/jk2/v2.0.0/doc/index.html

          • 2. Re: Mapping vitual servers to .war files
            stiphout

            Already using mod_jk2 - just can't figure out how to set it up to do what I mentioned in my first post...

            • 3. Re: Mapping vitual servers to .war files
              maheshkudva

              Hi

              Were you able to figure out how to do it. I am also facing the same situation

              Regards
              Mahesh

              • 4. Re: Mapping vitual servers to .war files
                maheshkudva

                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
                </VirtualHost>
                

                -------------------------------------------------------------------------
                mod-jk.conf
                ================
                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
                </Location>
                

                --------------------------------------------------------------------------
                Server.xml
                ---------

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

                --------------------------------------------------------------------------
                --
                uriworkermap.properties
                ================
                /jmx-console=loadbalancer
                /jmx-console/*=loadbalancer
                /web-console=loadbalancer
                /web-console/*=loadbalancer
                /webapp.domain.com/*.jsp
                

                --------------------------------------------------------------------------
                --
                workers.properties
                ================
                worker.list=loadbalancer,status
                
                worker.webapp.port=8009
                worker.webapp.host=webapp.domain.com
                worker.webapp.type=ajp13
                worker.webapp.lbfactor=1
                worker.webapp.cachesize=10
                
                worker.loadbalancer.type=lb
                worker.loadbalancer.balance_workers=library
                worker.loadbalancer.sticky_session=1
                worker.loadbalancer.local_worker_only=1
                worker.list=loadbalancer
                
                worker.status.type=status
                


                Regards & Thanks
                ================
                Mahesh S Kudva
                Network Analyst
                Robosoft Technologies