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 www.books.com, 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 www.autos.com and these requests are targeted to WebLogic Servers D and E. 




To Create & Test a Virtual Host 


1. 
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 -


127.0.0.1       localhost mukeshnegi.com





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

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


4.
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 )

6.
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 127.0.0.1:80 for protocols http.>

7.
Now instead of http://<server>:<port>/your_apps_url, access it like http://mukeshnegi.com/your_apps_url

For example - 

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


2 comments:

  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.

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

    ReplyDelete