Monday, October 18, 2010

Weblogic Virtual Host : Working with Virtual Hosts

Weblogic Virtual Host : Working with Virtual Hosts

Virtual hosting allows you to define host names that servers or clusters respond to. 

When you use virtual hosting you use DNS to specify one or more host names that map to the IP address of a WebLogic Server instance or cluster, and you specify which Web Applications are served by the virtual host. 

When used in a cluster, load balancing allows the most efficient use of your hardware, even if one of the DNS host names processes more requests than the others.

For example :-  

you can specify that a Web Application called books responds to requests for the virtual host name, and that these requests are targeted to WebLogic Servers A,B and C, while a Web Application called cars responds to the virtual host name and these requests are targeted to WebLogic Servers D and E. 

To Create & Test a Virtual Host 

Edit your hosts file and map your domain / DNS name to the server ip address. 
Unix - /etc/hosts
Window - C:\WINDOWS\system32\drivers\etc\hosts

In Window entry should be like below -       localhost

Create a virtual host, Click on Virtual Hosts, New, Enter name for virtual host.

Click on name of virtual host and in "Virtual Hosts Names" field enter your domain name like here,, if you more then one domain name mapped enter each separated by comma

Click on target tab and select managed or admin server wherever you want to target, 

5. Deploy your application on virtual host ( select deployment to deploy and target should be virtual host )

Create a channel
Click on managed or admin server on which you you targeted to virtual host, select channels under protocols on right hand side
Click on new
Enter channel name & select protocol http, select next

Enter port 80, select next

Select default options and click next
Select default option and click next
Click on finish

Now, you can see below lines in the server log file on which you targeted the virtual host -

<Oct 18, 2010 10:52:18 PM IST> <Notice> <Server> <BEA-002613> <Channel "Channel-
0" is now listening on for protocols http.>

Now instead of http://<server>:<port>/your_apps_url, access it like

For example - 

if you access your apps like http://localhost:7002/shoppingcart/welcome.jsp then access it like    http://mukeshnegi/shoppingcart/welcome.jsp


  1. Is it possible to do the same thing with WLST ? I am looking for a solution to solve this problem : I want to declare VirtualHosts by scripting.

  2. on unix env port 80 will start with weblogic user ?