CopyDisable

Wednesday, 15 May 2013

Configuring Virtual Servers in Glassfish

Using Virtual Server we can host multiple websites in a single glassfish domain. If you are familiar with virtual hosting in web servers, it is the same feature as virtual hosting.

Here I will configure two applications app1 and app2 in one Glassfish server. The requirement is that app1.test.com and app1new.test.com should open the app1 application. Also app2.test.com and app2new.test.com  should open app2 application.

Both the applications are deployed in domain1 of my glassfish server.

First I will change the default HTTP port for Glassfish domain1 so that it listen to port 80. Go to server-config –> Network Config –> Network Listeners –> http-listener-1

Change to Port to 80 and save it.

image

 

 

Now I will create Virtual Server for the first application (app1).

Login to Glassfish Admin console.

Go to Configurations –> server-config –> Virtual Servers

image

 

By default we can see the two Virtual Servers, _asadmin and server:

image

 

Click on the New button to create the new Virtual Server for app1.

Enter ID for this configuration, Glassfish will refer the new Virtual Server using this name.

Hosts: This will be the comma separated list of hosts or IP address using which we gonna access this application. For the app1 it will be app1.test.com and app1new.test.com 

Select State as On – Virtual server active

As I don’t need single sign on, so I kept SSO disabled.

Select the Network Listeners which will be attached to this Virtual Server.

Select the Default Web Module as app1 (the default application that will be accessed using this virtual server).

Enter the error and access log file locations if you want separate access and error logs for this Virtual server.

Now in Docroot I have entered the location where my application app1 resides i.e.  ${com.sun.aas.instanceRoot}/applications/app1/

Click Ok to create the Virtual Server.

 

image

 

Same way I will create the second virtual server for my second application app2.

image

 

That’s it, my virtual servers are ready and now I can directly open app1.test.com, app1new.test.com and app2.test.com, app2new.test.com without specifying context path Smile

4 comments:

Loc Ha said...

Thanks for great post.

Do you know how to configure SSO across 2 virtual servers? In your case, I want SSO for App1, App2

Pranab Sharma said...

Hi, I never tried SSO across virtual servers. I think SSO is domain specific and may not work across different virtual servers.

raghu-appsdba said...

class java.lang.RuntimeException am getting this error when am try to create new virtual machine.

Anonymous said...

Pranab'S Scrapbook: Configuring Virtual Servers In Glassfish >>>>> Download Now

>>>>> Download Full

Pranab'S Scrapbook: Configuring Virtual Servers In Glassfish >>>>> Download LINK

>>>>> Download Now

Pranab'S Scrapbook: Configuring Virtual Servers In Glassfish >>>>> Download Full

>>>>> Download LINK

Post a Comment