4 Replies Latest reply on Dec 20, 2004 5:19 PM by jimxchen

    Mapping virtual hosts to webapplications/context

    toni

      Hello,

      I have set up apache 1.3.31 with jboss-4.0.0 and tomcat 5.0.x successfully.

      What I would like to do now is to map each virtual hosts to a webapplication.

      The important point here is that I would like this do be done in a manner, so that typing in the domain solely will invoke the webapplication.

      To illustrate a virtual example. Assume I have set up the following virtual host entries:

      webcontext1.domainname.com
      webapplication2.domainname.com
      context3.domainname.com

      Let's assume further that I have mapped them in the same order to the following webapplications, which ship with jboss 4.

      /jmx-console
      /web-console
      /status

      In fact I have managed to do something very similar at home. I can also invoke the webapplication BUT I have to append the context path.

      So I can start the webapplication in the jmx-console.war by entering the following url into my browser: webcontext1.domainname.com/jmx-console

      This works at home. The webapplication is invoked. This works because I have added a vitural host entry and added the "JkMount /jmx-console ajp13worker" line to the virtual host.

      However, I would like that only calling the url "webcontext1.domainname.com" will invoke the webapplication. I do not want to append the context-path. Of course that makes a lot of sense.

      Unfortunaltey I don't know how to do this and so I would appreciate any help on the subject.

      Maybe somebody from the JBoss Group can help here? I think this is a setup which many users are interested in.

      Thanks,
      Toni

        • 1. Re: Mapping virtual hosts to webapplications/context

          Give apache mod_rewrite a look.

          • 2. Re: Mapping virtual hosts to webapplications/context
            toni

            Actually I solved the problem myself. So to share the knowlege with you here comes the solution.

            The only thing you have to do is to add a virtual host and root context entry to jboss-web.xml. That's it.

            Actually I did this also but their was (stupid me) a spelling mistake. Can't believe it but that was just the problem with the setup.

            So, for the example below your jboss-web.xml for the jmx-console should contain:

            <root-context>/</root-context>
            <virtual-host>webcontext1.domainname.com</virtual-host>

            The same holds true for the othe apps...

            • 3. Re: Mapping virtual hosts to webapplications/context
              icordoba

              Hi there,
              can anybody confirm that this works with JBoss-4's Tomcat? I can make virtual host work in jboss-web.xml, but cannot use the <root-context> tag to position it at the root context of the virtual host.
              Am I missing something?

              Thanks,
              Ignacio

              • 4. Re: Mapping virtual hosts to webapplications/context
                jimxchen

                Hi Toni,

                Just read your message posted here. I am new to this technology and want to run a couple of domain names on my machines. I tried to have the two lines below:

                <root-context>/name2</root-context>
                <virtual-host>www.name2.com</virtual-host>



                Could you please tell me whre is the "name2" directory that I should put the index.html?



                Thank you very much.

                Best regards,

                --Jim