users@glassfish.java.net

Re: Another thread on virtual servers

From: <glassfish_at_javadesktop.org>
Date: Fri, 01 Aug 2008 09:15:24 PDT

OK, everything is working now as expected. For those who are interested, here is how to set up multiple virtual servers on one http-listener (or in my case, one http and one https listener) and not have the problem of http://www.def.com loading the abc app and https://www.abc.com loading the def app:

1) Add a virtual server for each webapp.
2) In each virtual server setting, set the Default Web Module to the applicable webapp
3) Create ANOTHER webapp (I called mine Redirector) that contains only a single JSP or servlet that checks the request.getRequestURL() value for your domain, and uses response.sendRedirect() to direct it to the correct website.
4) Create another virtual server for the Redirector webapp
5) Set the Default Virtual Server on the http listener to use the Redirector virtual server
6) Double check your virtual servers to make sure they are all using the correct http listeners
5) When you deploy your web app, make sure you set the correct virtual server to associate it with in Applications -> Web Applications
6) Restart Glassfish with stop-domain/start-domain.

Voila!
[Message sent by forum member 'malakh' (malakh)]

http://forums.java.net/jive/thread.jspa?messageID=290973