How requests map to virtual host aliases

 

+

Search Tips   |   Advanced Search

 

Virtual hosts let you manage a single application server on a single machine as if the application server were multiple application servers that are each on their own host machine. Resources associated with one virtual host cannot share data with resources associated with another virtual host, even though the virtual hosts share the same application server on the same physical machine.

When you request a resource, WAS tries to map the request to an alias of a defined virtual host.

Mappings are both case sensitive and insensitive. For example, the portion "http://host:port/" is case insensitive, but the URL that follows is case sensitive. The match must be alphanumerically exact. Also, different port numbers are treated as different aliases.

For example, the request...

http://www.myhost.com/myservlet

...maps successfully to...

http://WWW.MYHOST.COM/myservlet

...but not to...

http://WWW.MYHOST.COM/MYSERVLET

...or...

Www.Myhost.Com/Myservlet

In the latter two cases, these mappings fail due to case sensitivity. The request...

http://www.myhost.com/myservlet

...does not map successfully to...

http://myhost/myservlet

...or to...

http://myhost:9876/myservlet

These mappings fail because they are not alphanumerically correct.

Use wildcard entries for aliases by port and specify that all valid host name and address combinations on a particular port map to a particular virtual host.

If you request a resource using an alias that cannot be mapped to an alias of a defined virtual host, you receive a 404 error in the browser that was used to issue the request. A message states that the virtual host could not be found.

Two sets of associations occur for virtual hosts. Application deployment associates an application with a virtual host. Virtual host definitions associate the network address of the machine and the HTTP transport or Web server port assignment of the application server with the virtual host. Looking at the flow from the Web client request for the snoop servlet, for example, the following actions occur:

  1. The Web client asks for the snoop servlet: at Web address http://www.some_host.some_company.com:9080/snoop

  2. The some_host machine has the 9080 port assigned to the stand-alone WebSphere Application Server, server1.

  3. The server1 Application Server looks at the virtual host assignments to determine the virtual host that is assigned to the alias some_host.some_company.com:9080.

  4. The application server finds that no explicit alias for that DNS string exists. However, a wild card assignment for host name * at port 9080 does exist. This is a match. The virtual host that defines the match is default_host.

  5. The application server looks at the applications deployed on the default_host and finds the snoop servlet.

  6. The application server serves the application to the Web client and the requester is able to use the snoop servlet.

We can have any number of aliases for a virtual host. We can even have overlapping aliases, such as:

Virtual host Alias Port
default_host * 9080
localhost 9080
my_machine 9080
my_machine.my_company.com 9080
localhost 80

The Application Server looks for a match using the explicit address specified on the Web client address. However, it might resolve the match to any other alias that matches the pattern before matching the explicit address. Simply defining an alias first in the list of aliases does not guarantee the search order when WAS is looking for a matching alias.

A problem can occur if you use the same alias for two different virtual hosts. For example, assume that you installed the default application and the snoop servlet on the default_host. You also have another virtual host called the admin_host. However, you have not installed the default application or the snoop servlet on the admin_host.

Assume that you define overlapping aliases for both virtual hosts because you accidentally defined port 9080 for the admin_host instead of port 9060:

Virtual host Alias Port
default_host * 9080
localhost 9080
admin_host * 9060
my_machine.com 9080

Assume that a Web client request comes in for http://my_machine.com:9080/snoop.

If the application server matches the request against *:9080, the application is served from the default_host. If the application server matches the request to my.machine.com:9080, the application cannot be found. A 404 error occurs in the browser that issues the request. A message states that the virtual host could not be found.

This problem is the result of not finding the requested application in the first virtual host that has a matching alias. The correct way to code aliases is for the alias name on an incoming request to match only one virtual host in all of your virtual host definitions. If the URL can match more than one virtual host, one can see the problem just described.


 

Related Tasks

Configuring virtual hosts