13 Replies Latest reply on Feb 13, 2009 12:36 AM by sun kum

    Configuring virtual host in jboss-4.2.0.GA?

    Tom Garcia Newbie

      I was able to setup virtual hosts using jboss-4.0.5.GA but since I've updated to jboss-4.2.0.GA, the virtual hosts are not being recognized. Can someone shed some light on setting up a virtual host on jboss-4.2.0.GA?

        • 1. Re: Configuring virtual host in jboss-4.2.0.GA?
          Tobias Frech Apprentice

          Perhaps you could shed some light on what you did (in 4.0.5) and what is not working with 4.2.0?

          • 2. Re: Configuring virtual host in jboss-4.2.0.GA?
            Tom Garcia Newbie

            To setup a virtual host in 4.0.5, I edited the server.xml file located in ${JBOSS_HOME}/server/default/deploy/jbossweb-tomcat55.sar by changing the HTTP/1.1 Connector port to "80" and added a new < Host > element below the existing < Host name="localhost" > element. Next, I added a <virtual-host> element to ${APP_NAME}.war/WEB-INF/jboss-web.xml (listed below).


            <?xml version="1.0" encoding="UTF-8"?>
            <!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.3V2//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_3_2.dtd">

            <jboss-web>
            <context-root>/</context-root>
            <virtual-host>somehost.com</virtual-host>
            </jboss-web>

            This worked without any problems at all.

            When attempting to setup a virtual host with 4.2.0, the structure had changed a bit so I took my best shot by changing the system variable (JBOSS_HOME) to point to the new installation and modifying the server.xml file located in ${JBOSS_HOME}/server/all/deploy/jboss-web.deployer/server.xml. I changed the HTTP/1.1. Connector port to "80", added the new < Host > element below the existing < Host name="localhost" >. The application being deployed to the new virtual host has not changed (still contains the jboss-web.xml file specifying the virtual-host).

            If there's anything that I've overlooked, your assistance would be greatly appreciated.

            Thanks.

            • 3. Re: Configuring virtual host in jboss-4.2.0.GA?
              Kevin Hooke Newbie

              I just moved a webapp I had running on 4.0.1 to 4.2.0GA and I am using the same jboss-web.xml file in my webapp's WEB-INF - I have not modified the server.xml file though as you mention. My virtual host config is practically the same as yours and this is working ok for me:

              <?xml version="1.0"?>
              <!DOCTYPE jboss-web>
              <jboss-web>
               <context-root>/</context-root>
               <virtual-host>www.mydomainhere.com</virtual-host>
              </jboss-web>
              


              Kevin

              • 4. Re: Configuring virtual host in jboss-4.2.0.GA?
                Tom Garcia Newbie

                Thanks for the reply Kevin. If I don't add the new < Host > entries in server.xml, I get the following error.

                12:03:37,589 WARN [TomcatDeployer] Failed to map vhost: epic-test.vetco.com
                12:03:37,589 INFO [TomcatDeployer] deploy, ctxPath=/, warUrl=.../tmp/deploy/tmp
                47811epic-exp.war/
                12:03:37,651 WARN [config] Unable to process deployment descriptor for context
                'null'
                12:03:37,870 WARN [config] Unable to process deployment descriptor for context
                'null'
                12:03:37,901 WARN [config] Unable to process deployment descriptor for context
                'null'
                12:03:37,948 WARN [config] Unable to process deployment descriptor for context
                'null'
                12:03:37,979 WARN [config] Unable to process deployment descriptor for context
                'null'
                12:03:38,026 WARN [config] Unable to process deployment descriptor for context
                'null'
                12:03:38,057 WARN [config] Unable to process deployment descriptor for context
                'null'
                12:03:38,089 WARN [config] Unable to process deployment descriptor for context
                'null'
                12:03:38,120 WARN [config] Unable to process deployment descriptor for context
                'null'
                12:03:38,198 INFO [TomcatDeployer] deploy, ctxPath=/jmx-console, warUrl=.../dep
                loy/jmx-console.war/
                12:03:38,370 INFO [Http11Protocol] Starting Coyote HTTP/1.1 on http-127.0.0.1-8
                0
                12:03:38,386 INFO [AjpProtocol] Starting Coyote AJP/1.3 on ajp-127.0.0.1-8009
                12:03:38,401 INFO [Server] JBoss (MX MicroKernel) [4.2.0.GA (build: SVNTag=JBos
                s_4_2_0_GA date=200705111440)] Started in 19s:703ms

                If I add the virtual-host to my hosts file and point it to 127.0.0.1, the app works when accessing it locally but from outside the server I still get a DNS error. The host that I am trying to setup is registered with DNS and works if using jboss-4.0.5.GA. When pinging the new virtual host, it resolves to the correct IP address.
                ..... it just doesn't resolve with 4.2.0.GA.

                • 5. Re: Configuring virtual host in jboss-4.2.0.GA?
                  Mike Rosseel Newbie

                  Hi,

                  Just ugraded from 4.0.5 to 4.2 myself, and I'm having no problems with the virtual hosts.

                  I did notice when copying my server.xml changes to the 4.2 server.xml that one classname changed (inside the HOST tag). So please compare your entries against the standard 4.2 localhost entry.

                  regards,
                  Mike

                  • 6. Re: Configuring virtual host in jboss-4.2.0.GA?
                    Tom Garcia Newbie

                    Hi Mike. Are you setting up a virtual host for local development where you have entered the virtual host in your hosts file or were you successful at setting up the virtual host that relies on the DNS server to resolve the IP address? The latter is the problem that I'm having. I can setup the virtual host for my local development environment but I'm having problems with 4.2.0 resolving the IP from the DNS server when trying to access the site from a remote machine.

                    Below is one of my < Host > entries in server.xml:

                    <Server>
                     <Service name="jboss.web">
                    
                     <Connector port="80" address="${jboss.bind.address}"
                     maxThreads="250" maxHttpHeaderSize="8192"
                     emptySessionPath="true" protocol="HTTP/1.1"
                     enableLookups="false" redirectPort="8443" acceptCount="100"
                     connectionTimeout="20000" disableUploadTimeout="true" />
                    
                     <!-- Define an AJP 1.3 Connector on port 8009 -->
                     <Connector port="8009" address="${jboss.bind.address}" protocol="AJP/1.3"
                     emptySessionPath="true" enableLookups="false" redirectPort="8443" />
                    
                     <Engine name="jboss.web" defaultHost="localhost">
                    
                     ........
                    
                    <Host name="epic-test"
                     autoDeploy="false" deployOnStartup="false" deployXML="false"
                     configClass="org.jboss.web.tomcat.security.config.JBossContextConfig"
                     >
                     <Alias>epic-test.mydomain.com</Alias>
                     <Valve className="org.jboss.web.tomcat.service.jca.CachedConnectionValve"
                     cachedConnectionManagerObjectName="jboss.jca:service=CachedConnectionManager"
                     transactionManagerObjectName="jboss:service=TransactionManager" />
                    </Host>
                    
                     </Engine>
                     </Service>
                    </Server>
                    


                    As mentioned previously, my virtual hosts work fine when using 4.0.5.

                    Thanks,
                    Tom

                    • 7. Re: Configuring virtual host in jboss-4.2.0.GA?
                      Vincent LAUGIER Newbie

                      Hello,

                      I hope this discussion is not closed because I have the same problem with jboss_eap_4.2.0_CP1

                      I have followed instructions on http://wiki.jboss.org/wiki/Wiki.jsp?page=VirtualHosts hoping that the configuration for jboss 4.0 also works for 4.2 (unlike Tom I do not know if my configuration would work on jboss 4.0)

                      This is what I get with :
                      http://www.mydomain.fr leads me to the jboss default page JBOSS_HOME/server/production/deploy/jboss-web.deployer/ROOT.war/index.html

                      http://mydomain.fr leads me to a blank page


                      http://www.orangeadomicile.fr/portalOAV2 and http://orangeadomicile.fr/portalOAV2 lead to the application

                      The server.xml configuration is :

                      <Connector port="80" address="${jboss.bind.address}"
                       maxThreads="250" maxHttpHeaderSize="8192"
                       emptySessionPath="true" protocol="HTTP/1.1"
                       enableLookups="false" redirectPort="8443" acceptCount="100"
                       connectionTimeout="20000" disableUploadTimeout="true" />
                      
                      [...]
                      
                      
                      <Host name="orangeadomicile.fr"
                       autoDeploy="false" deployOnStartup="false" deployXML="false">
                       <Alias>orangeadomicile.fr</Alias>
                       <Alias>www.orangeadomicile.fr</Alias>
                       <Valve className="org.apache.catalina.valves.AccessLogValve"
                       prefix="orangeadomicile.fr-120-" suffix=".log"
                       pattern="common" directory="${jboss.server.home.dir}/log"/>
                       </Host>
                      
                      


                      and jboss-web.xml

                      <?xml version="1.0"?>
                      <!DOCTYPE jboss-web>
                      <jboss-web>
                       <virtual-host>orangeadomicile.fr</virtual-host>
                      </jboss-web>
                      

                      or (I do not quite understand the difference, but I have seen both on forums)
                      <?xml version="1.0"?>
                      <!DOCTYPE jboss-web>
                      <jboss-web>
                       <context-root>/portalOAV2</context-root>
                       <virtual-host>orangeadomicile.fr</virtual-host>
                      </jboss-web>
                      


                      We have configured the DNS for this domain in the same manner as for our other domains pointing to apache websites. That is to say we tell the DNS server to point this domain name to this IP adress, we cannot specify more I think on the DNS side.

                      What we want is achieve the same thing as in apache, in apache we would have written for a domain name albumus.fr
                      <VirtualHost our IP adress:80>
                       ServerAdmin vincent.laugier@helmet.fr
                       ServerName www.albumus.fr
                       ServerAlias www.albumus.fr albumus.fr
                       DocumentRoot /var/www/album/
                       <Directory /var/www/album>
                       AllowOverride All
                       Allow from all
                       </Directory>
                       ErrorLog /var/www/album/logs/error.log
                       LogLevel warn
                       CustomLog /var/www/album/logs/access.log combined
                       ServerSignature Off
                      </VirtualHost>
                      


                      Note : jboss is not running locally, so changin /etc/hosts is no use

                      I hope you Tom or someone else have found a solution, documentation is scarce

                      regards

                      Vincent

                      • 8. Re: Configuring virtual host in jboss-4.2.0.GA?
                        Tom Garcia Newbie

                        Your jboss-web.xml should specify the context root as "/" for apps deployed to a virtual host.

                        <?xml version="1.0"?>
                        <!DOCTYPE jboss-web>
                        <jboss-web>
                         <context-root>/</context-root>
                         <virtual-host>orangeadomicile.fr</virtual-host>
                        </jboss-web>
                        


                        You will want to make sure that you secure your web-console and jmx-console as well. When you setup your virtual hosts in jboss, these are accessed by http://{IP_ADDRESS}/web-console/.



                        • 9. Re: Configuring virtual host in jboss-4.2.0.GA?
                          Vincent LAUGIER Newbie

                          yes, I forgot to say that I also tried this

                          <?xml version="1.0"?>
                          <!DOCTYPE jboss-web>
                          <jboss-web>
                           <context-root>/</context-root>
                           <virtual-host>orangeadomicile.fr</virtual-host>
                          </jboss-web>
                          


                          But still, it does not work.

                          About the web-console and the jmx-console, I also get the blank page :

                          http://{IP_ADDRESS}/web-console/
                          http://{IP_ADDRESS}/jmx-console/

                          thanks for your help

                          • 10. Re: Configuring virtual host in jboss-4.2.0.GA?
                            Tom Garcia Newbie

                            You may need to add a jboss-web.xml file to the default localhost. If you do not have this file in {JBOSS_HOME}/server/default/deploy/jboss-web.deployer/ROOT.war/WEB-INF/, then add the file to this directory.

                            <?xml version="1.0"?>
                            <!DOCTYPE jboss-web>
                            <jboss-web>
                             <context-root>/</context-root>
                            </jboss-web>
                            


                            Notice that there is no virtual host specified because your server.xml specifies that the default host is localhost.

                            server.xml:
                            [...]
                            
                             <!-- Define an AJP 1.3 Connector on port 8009 -->
                             <Connector port="8009" address="${jboss.bind.address}" protocol="AJP/1.3"
                             emptySessionPath="true" enableLookups="false" redirectPort="8443" />
                            
                             <Engine name="jboss.web" defaultHost="localhost">
                            
                            [...]
                            
                            <Host name="localhost"
                             autoDeploy="false" deployOnStartup="false" deployXML="false"
                             configClass="org.jboss.web.tomcat.security.config.JBossContextConfig"
                             >
                            
                            [...]
                            </Host>
                            
                            <!-- Define virtual hosts -->
                            <Host name="mydomain.com" .... </Host>
                            
                             </Engine>
                             </Service>
                            </Server>
                            




                            • 11. Re: Configuring virtual host in jboss-4.2.0.GA?
                              Maria Consuelo Franky Newbie

                              Hello:

                              I have followed your indications but I do not have success when I configure a virtual host in JBoss 4.2.0 GA in a MS-Windows XP computer.

                              1- I have added a Host section in the server.xml file:

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


                              Here myserver.mydomain.com is registered in the hosts file and it is associated to the IP of my Windows computer; this computer is seen by the other computers in the local network.

                              2- I have put a jboss-web.xml file in my application:
                              <jboss-web>
                               <context-root>/myProj</context-root>
                               <virtual-host>localhost</virtual-host>
                               <virtual-host>myserver</virtual-host>
                              </jboss-web>


                              Whe I deploy my application I can enter to :
                              http://localhost:8080/myProj

                              but I can not get to enter to:
                              http://myserver.mydomain.com:8080/myProj

                              My question is if it is not possible to configurate virtual hosts in JBoss 4.2.0 GA in a MS-Windows XP computer ?

                              I have not had this problem in Linux computers.

                              Thanks for any help.

                              Maria Consuelo Franky


                              • 12. Re: Configuring virtual host in jboss-4.2.0.GA?
                                Maria Consuelo Franky Newbie

                                I have resolved the problem of defining virtual hosts in JBoss 4.2.0 GA. The steps are:

                                1-To add a Host section in the server.xml file

                                2- To put a jboss-web.xml file in the application

                                3- To launch the JBoss server bound to all addresses an not only to 127.0.0.1

                                run -b 0.0.0.0


                                The steps 1 and 2 were explained in this topic.
                                The step 3 was explained by Peter Johnson in
                                http://www.jboss.com/index.html?module=bb&op=viewtopic&t=108595

                                Thanks to all

                                Maria Consuelo Franky

                                • 13. Re: Configuring virtual host in jboss-4.2.0.GA?
                                  sun kum Newbie

                                  any further input on that... Developers ? or we declare it as universal unresolved bug ?