IP Virtual Hosting


Virtual Hosting Using External Web Servers

Our examples thus far have assumed that the internal Web server is being used to pass requests from the client's Web browser to the servlet engine within Resin. As you recall from Chapter 16, you can use several external Web servers as front ends to Resin. This configuration turns Resin into an application server and ignores the internal Web server.

In these situations, you still want to be able to support virtual hosting. Fortunately, whether you're using Microsoft IIS or Apache as a front end, you don't have to modify the resin.conf configuration file—with one exception. Depending on how the domain for a site is set up using static IP addresses as such, you might need to use both the www.company.com and company.com domain strings for a successful match by the Resin server, as shown here:

 <server>   <host id='www.company.com'>     <host-alias>company.com</host-alias>   </host> </server> 

As for IIS, no other changes are required. If you have one host serving pages through IIS, then just add more hosts to provide virtual hosting. Apache, on the other hand, needs a little help when you're specifying more than one host. First, don't change anything in the Resin configuration file—this file does not have to be modified.

However, you do have to add appropriate <VirtualHost> elements within Apache's httpd.conf file. Consider the following snippet using our two sample domains:

 LoadModule caucho_module /usr/local/apache/libexec/mod_caucho.so AddModule mod_caucho.c CauchoConfigFile /home/www/conf/resin.conf <VirtualHost 134.154.45.65>   ServerName www.company.com </VirtualHost> <VirtualHost 134.154.45.67>   ServerName www.ourcompany.com </VirtualHost> 

In this Apache httpd.conf file, we start by loading the caucho_module and then the Resin configuration file. It is very important that these two steps occur in the order shown in the example. Next, <VirtualHost> elements are defined for each of the domains being hosted. The most important part of these two definitions is the use of ServerName. The value associated with ServerName is the domain name passed to Resin for matching against the various <host> elements in the Resin configuration file. If the values for ServerName aren't accurate, the Resin server will not find the associated <host> configuration.




Mastering Resin
Mastering Resin
ISBN: 0471431036
EAN: 2147483647
Year: 2002
Pages: 180

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