Virtual Hosting

Virtual hosting is the ability to run multiple web sites say, www.domain1.com and www.domain2.com on a single web server. Name-based virtual hosting implies that you map multiple domain names (or logical hosts) to the same IP address. The fact that both web sites run on the same server is not apparent to the clients. WebLogic Server allows you to create a virtual host for any number of different domain names. For instance, using DNS you could create two different domain names v1.oreilly.com and v2.oreilly.com pointing to the same physical WebLogic instance. On this single instance you can create two virtual hosts say, v1 and v2.

If you have two virtual hosts, you can configure the web server to behave in the following ways:

  • You can modify the HTTP behavior of each virtual host independently. For instance, each virtual host can have its own HTTP access logs.
  • You can associate a different default web application with each virtual host in the same way that you associate a default web application with a WebLogic Server.
  • You can target different WebLogic servers or clusters to different virtual hosts. For instance, if you have mapped different web applications to the virtual hosts, and targeted the web applications to different WebLogic servers, you can effectively target the virtual hosts to the appropriate servers.

Identical web applications are then isolated from each other when they are targeted to different virtual hosts.

The Servlet specification demands that each logical virtual host must have its own servlet context, and that servlet contexts cannot be shared across virtual hosts.

 

3.2.1 Creating Virtual Hosts

Before you set up virtual hosts on WebLogic Server, you need to ensure that you have mapped the desired domain names to the same IP address. In our earlier example, the DNS server would have mapped v1.oreilly.com and v2.oreilly.com to the machine's IP address. Now to create a virtual host, you need to perform the following steps from the Administration Console:

  1. Select the Services node, then the Virtual Hosts node.
  2. Choose "Configure a new Virtual Host" in the right frame.
  3. Enter a name for the virtual host. This is needed only to identify the Virtual Host entry in the domain.
  4. Enter the names of the virtual hosts as you've configured them in the DNS server. In our example, the name of the virtual host would be v1.oreilly.com. In fact, you can enter the names of multiple virtual hosts here (one per line). This ensures that you have identical settings for each virtual host.
  5. You may additionally configure the HTTP logging settings, and HTTP configuration parameters that are specific to the virtual host(s).

Once you have created a virtual host, you will notice an additional entry for it under the Target tab of any web application. If you want to target an application to a virtual host, select the virtual host as a target, and then move to the Target & Deploy tab to deploy the application to the targeted virtual host.

In order to set up the virtual host, you should remember to configure the server instances or cluster that will respond to the virtual host and target the web applications to the particular virtual host(s). If you omit either of these steps, the virtual host will not respond properly.

 

3.2.2 A Virtual Hosting Scenario

Let us consider a small scenario and examine how WebLogic resolves URLs to particular web resources. Imagine that your WebLogic deployment consists of two virtual hosts, corresponding to the two domains v1.oreilly.com and v2.oreilly.com. Let's target an application app1 to host v1 only, and app2 to v1 and v2. Furthermore, imagine that app1 has a context root of app1, and app2 has a context root of /.

Now, consider what happens when a client requests the following URLs:

http://v1.oreilly.com/index.jsp

This URL requests /index.jsp from the default web application targeted to host v1. This implies the URL resolves to /index.jsp from the web application app2.

http://v2.oreilly.com/index.jsp

Again, this URL requests /index.jsp from the default web application targeted to host v2. This implies the URL resolves to /index.jsp from the web application app2.

http://v2.oreilly.com/app1/index.jsp

This URL attempts to request /index.jsp from the web application app1. In this case, the client will receive an HTTP 404 Resource Not Found error response because the web application app1 has not been not targeted to host v2.

http://v1.oreilly.com/app1/someservlet

This URL points to the servlet mapped to /someservlet within the web application app1. A client will be able to access this resource because app1 was targeted to host v1.

Introduction

Web Applications

Managing the Web Server

Using JNDI and RMI

JDBC

Transactions

J2EE Connectors

JMS

JavaMail

Using EJBs

Using CMP and EJB QL

Packaging and Deployment

Managing Domains

Clustering

Performance, Monitoring, and Tuning

SSL

Security

XML

Web Services

JMX

Logging and Internationalization

SNMP



WebLogic. The Definitive Guide
WebLogic: The Definitive Guide
ISBN: 059600432X
EAN: 2147483647
Year: 2003
Pages: 187

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net