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:
Identical web applications are then isolated from each other when they are targeted to different 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:
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.
|
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