Virtual Hosts

Virtual hosting, which defines a set of host names to which WebLogic Server instances (servers) or clusters respond. When you use virtual hosting, you use DNS to specify one or more host names that map to the IP address of a server or cluster.

When you deploy the application on virtual host, it means you hide the IP address of the servers which are actually going to serve the requests.

It can either be targeted to one individual server or the whole cluster.

In my example, I have configured a virtual host for the admin server. Below are the steps we need to follow:

1)    The first requirement for creating a virtual host is to create a network channel on the admin server.
-    Go to the admin console, click on servers -> admin server
-    Go to the Protocols -> Channel tab
-    Give the name of the channel as port-80, choose the protocol as http.
-    Give listen address as localhost, give the listen port as 80. Leave the external listen address and port bank.
-    Enable HTTP tunneling as per your preference.
-    Leave the security part as it is to the default unchecked values.
-    You will see the below configuration once the channel is created.

- Restart the server to confirm that the server is using the default channel and port-80 channel.

2) Once the network channel is created, go to Environment -> Virtual hosts
- Click on new, give a name to the host vh.localhost.org.
- Now click on the virtual host vh.localhost.org, give the below values:
Virtual Host Names:  vh.localhost.org
Network Access Point Name: port-80

-    Click on targets tab, check the admin server.
-    Save the changes and restart the server.

3)    Now we need to modify the windows host file in C:\WINDOWS\system32\drivers\etc directory and add the host name vh.localhost.org which we have specified for the virtual host. Add the below in the file:
127.0.0.1    vh.localhost.org

4) Now deploy one test application following the below steps:
- Click on deployments
- Click on install -> Choose the application from the path
- Click next, check Install this deployment as an application -> target it to the virtual host (not the server)

- Click finish

Deployment state should be active.

Now access the application using the url:

http://vh.localhost.org/web-app

You should see the welcome page of the application.

29 Thoughts on “Virtual Hosts Configuration with Weblogic Server

  1. Amarender on November 24, 2010 at 12:38 am said:

    really very helpful document…thanks a ton.

  2. I just wanted to say that you deserve two thumbs up for your hard work.

  3. Hi Divya,

    Is there a way to deploy applications and target them to virtual hosts using WLST ?

    I have tried to do even the recording option but it was useful.

    Thanks in Advance.

    Regards,
    Kiran

  4. Hi Kiran,

    Yes targeting the application to virtual host using WLST can be done as below:

    - Once you are connected to the server, enter the online command:
    deploy(appName=’web-app’, path=’C:\web-app’, targets=’vh.localhost.org’)

    vh.localhost.ors is the virtual host. It will look like below:

    ==================
    wls:/Channel_vh_domain/serverConfig> deploy(appName=’web-app’, path=’C:\web-app’, targets=’vh.localhost.org’)
    Deploying application from C:\web-app to targets vh.localhost.org (upload=false) …

    .Completed the deployment of Application with status completed
    Current Status of your Deployment:
    Deployment command type: deploy
    Deployment State : completed
    Deployment Message : no message

    Let me know if this works for you.

    Regards,
    Divya

  5. Divya

    Thanks very much,it realy good document…..

    Cheers
    Subbu

  6. Thanks a lot Subbu :)

  7. madhukar on December 22, 2010 at 3:16 pm said:

    Thanks a lot .This is a really good document, i enjoyed a lot

  8. madhukar on December 23, 2010 at 2:46 pm said:

    Hey Divya
    in url is it manadatory to specify the port number in virtualhost ?
    i have tried one example , if i am not giving the port application is not working .in above exaple you haven’t given the port. is any specific rule for giving thevirtualhost name ( means how many character and dots ican give ex:- vh.madhu.test.org can i use this ?

  9. Hi Madhukar,

    In the above example, the port number i have given is 80. And this port number does not need to be entered in the url. If you give any other port number, for e.g. if i have port number as 7001, the url has to be something like http://vh.localhost.org:7001/web-app.

    For giving the virtual host name, there is no rule i know of. It can be a single word or there can be dots too. Let me know if these things work for you.

    Thanks!
    Divya

  10. Hi,

    Thanks for your document. I tried but not showing target server for vh.localhost.org. I am using weblogic 9. Please tell me how i can connect virtual host

  11. madhukar Gunda on January 4, 2011 at 10:10 am said:

    Thank you divya. If we are using other than port 80 we have to mention in th URL .. please correct me if i am wrong .

    In windows vista aprache proxy plugin is not working .
    Please suggest me is vista is not compatablie for proxying the requests WEBLOGIC AND APACHE.

    i am using the weblogic 9.2 and apache 2.2.x . Same was working fine in Windows XP

  12. Thanks so much for this post – I found such gobbledygook on the Oracle support discussions that I was beginning to despair. This is a lifesaver!

  13. Rennay on January 25, 2011 at 4:10 pm said:

    Thanks for this post – was really helpful and highly appreciated.

  14. Kishor on March 14, 2011 at 8:01 am said:

    I have question. If it will work without defining anything in Apache httpd.conf file.I think the virtual host entries must be reflect in this file also.
    please make me correct if I am wrong

  15. ananth on April 12, 2011 at 1:46 pm said:

    i have tried with virtualhost but i am getting some server side exception :
    503 Service Unavailable
    Failed to resolve the name of server vh.localhost.org to connect

    i have included the virtualhost in hosts file also
    logs are showing
    —————————————————————————

    [HttpServer (VirtualHost) name: vh.localhost.org hosts: [vh.localhost.org] channel: port-80] Initialized>

    can any one please help me on this

    Thanks in Advance

    cheers,
    Ananth

    • divya on April 19, 2011 at 9:12 am said:

      Hi Ananth,

      Can you give me a breif outline of the steps you have followed? I doubt this can be something to do with the network channel.

      Best Regards,
      Divya

  16. Thanks for the explanation. couple of questions.

    1) in step 4 , isnt the application required to be targeted to the admin server ?

    2) can you give some examples where the weblogic virtual hosting is used. I am little confused as to why to use weblogic virtual hosting when the same thing can be done using Apache or Iplanet in a much more efficient way.

    • divya on August 8, 2011 at 7:09 am said:

      Hi Ram,

      It would be targetted to the virtual host because that is the purpose of creating it. This virtual host is made for the admin server (check the step 1). If it is targeted to the admin server, virtual host cannot be used.

      About the second question, it depends on you what you prefer. Even in weblogic you can create many virtual hosts and target it to different set of servers or a cluster. It gives you a lot of flexibility.

      Best Regards,
      Divya

  17. ananth on August 7, 2011 at 3:13 am said:

    Divya,

    I have created http-channel with port “80″
    i have used same channel in virtual-host configuration after that i
    have modified hosts file
    i have deployed sample WAR file with weblogic-deployeer utility
    i have tried with http://vh.localhost.org/sample
    i got error like

    Failed to resolve the name of server vh.localhost.org to connect

    • divya on August 8, 2011 at 6:42 am said:

      Hi Ananth,

      Did you target that application to the virtual host? Also please tell me what exact error you are seeing after the line failed to connect? I hope you restarted the server after creating the virtual host.

      Best Regards,
      Divya

  18. sambasivarao on April 9, 2013 at 2:55 am said:

    how resolve in managed server starting time show admin mode.

  19. Prajitha Nambiar on July 31, 2013 at 11:26 pm said:

    very good document:) thanks much for updating this :)

  20. Thank you for sharing your info. I really appreciate
    your efforts and I am waiting for your next write ups thanks once again.

Leave a Reply

Post Navigation