WebSTAR 4 Manual & Technical Reference

Manual Contents | Chapter Contents | Previous Page | Next Page

Virtual Hosts

Virtual hosting allows you to serve several web sites, with different host names and even IP addresses, using the same WebSTAR server. Visitors to these sites will be routed by IP address, host name, and/or the browser Language setting to the correct Virtual Host, with its own default pages and web links.

See also: Identifying Your Site: IP, Host Name and DNS and Virtual Hosts: Hosting Multiple Web Sites .

Note that all hosts within WebSTAR share all other settings, including File Names, Caching, Suffix Mapping, CGIs and Plug-Ins, Security Realms, and Web Users and Passwords.

Before setting up your Virtual Hosts, you should do the following:

1 Read the section Virtual Hosts: Hosting Multiple Web Sites .
2 Work with your ISP or other DNS provider to register the domain names and direct them at your server (see DNS ).
3 If you want to run IP Multihoming, make sure you have version 1.3 or later of Open Transport and obtain additional IP addresses from your service provider.
4 Create Virtual Host root folders and subfolders for each host on the server within the WebSTAR folder hierarchy.
Each Virtual Host can also have different Index file names, and Error and No Access files. If you want to restrict access to the host to certain machines or user names and passwords, make sure that the folder name is will not match any other folder or file name on the server, so that it can be used as a Realm Match String.
See also Security Realms .
5 A few older browsers do not pass the HOST field in the HTTP header, so they cannot access Virtual Domains automatically. See About Virtual Domains for information about making your virtual hosts accessible to these browsers.

Editing Virtual Hosts Entries

To create and edit Virtual Hosts Entries, you will need to specify the IP address, host name, or language, using the Virtual Hosts table in the WebSTAR Admin Settings Window. When WebSTAR receives an HTTP request, it will consult this table to figure out which host should get the request. Each host can have a separate root folder and folder hierarchy, as well as default index file name and so on.

You must edit the Virtual Hosts using the WebSTAR Admin application: there is no Browser Admin page.

To make entries, just click the New button and fill in the fields. You should follow the instructions below to arrange your Virtual Hosts routing entries in the correct order, and see Working With Admin Lists for notes on creating, editing, moving, and deleting entries.

 

Special Routing Considerations

The first three columns in the routing table entry are IP address, host name, and language. Following the routing information is the virtual host root folder : the base folder for all HTML files for that host.

If the request matches all items with data in them for an entry, then the request is routed to that host. Be sure you follow the instructions below, or you may be surprised at the results.

For example, if the Host Name matches the request but the IP Address does not match, the entry is not matched.

If a request doesn't match any entries in the table, it will use the default host : the IP address and host name of the machine, the WebSTAR root folder, and the default names and files as defined in File Names and Paths .

Host Definition for Routing

The Host Definition fields allow you to specify the routing information, and the associated root folder, according to the instructions below.

Remember, the host name must be registered and the DNS entry enabled before the server will get requests for this host name.
 

IP Address Routing

Hosting web sites on several IP addresses requires configuration using Open Transport 1.3 or later (described in IP Multihoming: Special Configuration ). The IP Address popup menu reads the IP Secondary Addresses file in the Preferences folder of the current system disk, and allows you to specify the IP address for this host. If you have not set this up, you can't route by IP address, and the popup menu will only have the entries "Any" and your main IP address.

Example IP Address Entries

IP Address

Host Name

Language

Root Folder

192.168.0.2

Any

Any

:widgets:

192.168.0.3

Any

Any

:kkn:

192.168.0.4

Any

Any

:tch:

See also Routing to Virtual Hosts .

In simple cases, you can make a single entry for each IP address, and WebSTAR will route correctly. Just enter the IP address: do not include the host name. The browsers already know the host name, because they looked it up in the DNS entry for that IP address.

You can have several Virtual Domains for each IP address, see Combining IP Address, Host Name and Language Routing for instructions.

Virtual Domains (Host Name) Routing

If you are using Virtual Domains, you're relying on the browser to send the host name in the header. In that case, the server will check the Host Name item in each entry until it finds a match. The entire host name must match, although the capitalization does not have to be the same. You do not need to include an IP Address for this routing. If you leave the Host Name field blank, it will be considered an "any" entry.

Do not enter an IP address , just the host name. The browsers have already looked up the IP address.  

Example Host Name Entries

IP Address

Host Name

Language

Root Folder

Any

widgets.domain.com

Any

:widgets:

Any

knickknacks.domain.com

Any

:kkn:

Any

www.tchotchkeys.com

Any

:tch:

Any

Any

Any

:widgets:

See also: About Virtual Domains .

If none of the entries matches the host name in the URL, or there is no header information, the web server will route the request to the default host. However, it's best to add an explicit default entry, so you keep track of these requests.

Language

You can route to different Virtual Hosts according to the language in the browser request header. This is set in the browser preferences by the user. Use the Language popup menu to select any of the standard browser languages. You can choose an overall language, such as Spanish, or a specific regional version, such as Mexican Spanish.

Example Language Entries

IP Address

Host Name

Language

Root Folder

Any

Any

French

:mecanisme:

Any

Any

Spanish

:cositas:

Any

Any

Any

:widgets:

IP addresses and Host Names are not required for Language Routing.

If none of the entries matches the Language code in the URL, the web server will automatically route the request to the default host. Therefore, you should make an explicit entry, to remind yourself what will happen

Combining IP Address, Host Name and Language Routing

You can combine IP addresses, host names and/or language requirements in a single entry, for sophisticated routing to your Virtual Hosts. Remember that each URL header must match the entry exactly . The first exact match is the entry that will be used for routing that request. You should put the most specific entries first, and make sure you cover contingencies by putting general entries at the bottom. To move an entry to a better position, just select and drag the row.

Always test your Virtual Host Routing with a single element in each line before combining elements .

Complex Combined Example

In the following example, there are five different web sites, using the following elements:

In this example, we are hosting a site registered in France (.fr).

widgets for widget information in English

mecanisme for widget information in French, using the widgets.domain.fr host.

cositas for widget information in Spanish, using the widgets.domain.com host.

knickknacks ( knickknacks.domain.com , on 192.168.0.3)

tchotchkeys ( www.tchotchkeys.com on 192.168.0.3)

The routing table looks like this:

Example Combined Entries

IP Address

Host Name

Language

Root Folder

Any

knickknacks.domain.com

Any

:kkn:

Any

www.tchotchkeys.com

Any

:tch:

Any

widgets.domain.fr

Any

:mecanisme:

192.168.0.4

Any

Spanish

:cositas:

192.168.0.4

Any

French

:mecanisme:

Any

widgets.domain.com

Any

:widgets:

Any

www.domain.com

Any

:widgets:

192.168.0.4

Any

Any

:widgets:

192.168.0.3

Any

Any

:kkn:

In the example above:

Remember, the hosts are evaluated from top to bottom, so make sure that the host names are above the IP address entries.

Virtual Host Routing Display

The WebSTAR Web server monitor window will display the routing information at startup and every time you make a change to those settings. The display looks like this, with asterisks (*) replacing the word "Any":

 

WebSTAR Virtual Hosts
 
===============================
 
* knickknacks.domain.com * -> :kkn:
 
* www.tchotchkeys.com * -> :tch:
 
* widgets.domain.fr * -> :mecanisme:
 
192.168.0.2 * fr -> :mecanisme:
 
192.168.0.2 * es -> :cositas:
 
* widgets.domain.com * -> :widgets:
 
* www.domain.com * -> :widgets:
 
192.168.0.2 * * -> :widgets:
 
192.168.0.3 * * -> :kkn:

Virtual Host Root Folder s

Virtual Host Root Folder field specifies the folder designated as root for that host. The virtual hosts will work within this folder and its subfolders. This folder must be within the WebSTAR folder, for security. If the folder doesn't exist yet, you can create it on the server disk using the FTP server, if you have the correct permissions.

See also File Hierarchy and Virtual Hosting .

You can use the Choose button next to the Root Folder field in the Virtual Hosts panel. This will allow you to select the folder on your server disk. Or you can type the file path yourself.

For example, if your Virtual Host is using the knickknacks folder as its root folder, and it's in the WebSTAR folder, you could use either of these paths:

 
Web-HD:WebSTAR 3:kkn:
 
:kkn:

The first is an absolute file path from the hard drive, the second is a relative file path from the WebSTAR root folder, but either of them will indicate the correct location of the Virtual Host root folder.

See also File Names and Paths .

Virtual Host Options

 

Server

To correctly identify the Virtual Host, enter its name in the Server field. This is the name that will be used when the host builds full URLs for redirection and Plug-In use. It defines how the host will refer to itself. This is particularly important for IP address entries, language routing, and alternate host names, such as converting domain.com to www.domain.com .

Host names, even for Virtual Hosts, are also defined by the DNS entries for your IP addresses: see DNS for details.

Default File Name

For a given Virtual Host, you can override the default Index file names. If you leave this field blank, this Virtual Host will use all the Index file names you specified in the File Names and Paths panel field Index File Name .

Error and No Access Files

You can also specify different Error and No Access files for this Virtual Host. This allows you to give host-specific or language-specific error messages. For information on these settings, see File Names and Paths .

Virtual Hosts Settings File

The WebSTAR Virtual Hosts Settings file, in the Plug-Ins folder, stores the list of Virtual Hosts and their attributes. It is created after you enter the first Virtual Host using the WebSTAR Admin and save the information to the server. The WebSTAR Virtual Hosts Plug-In reads this file when the server starts up: when you see the list in the Virtual Hosts panel in WebSTAR Admin, it comes from this file.

Back up this file so you do not have to re-enter the Virtual Hosts settings if something happens to your disk or server machine.

Format of the Virtual Hosts Settings File

The file has the eight fields, corresponding to the fields in the WebSTAR Admin panel, with tabs between them. To specify that a field should be "Any", leave it blank, so there are two tabs together.

The fields are:

The first three are the routing information (see Special Routing Considerations ). After that, the root folder path (see Virtual Host Root Folders ), and options, as described in Virtual Host Options .

The last character in the file should be a CR (Carriage Return) at the end of the last entry.

In this example Tab characters are replaced with dashes:

-knickknacks.domain.com--:kkn:-knickknacks.domain.com-:kkn:error.html--:kkin:noaccess.html-1

-www.tchotchkeys.com--:tch:-www.tchotchkeys.com-:tch:error.htm--:kkn:noaccess.htm-2

-widgets.domain.fr-:mecanisme:-widgets.domain.fr-:mechanisme:erreur.html-indix.html--3

192.168.0.2-fr-:mecanisme:-widgets.domain.fr-:mechanisme:erreur.html-indix.html--4

192.168.0.2-es-:cositas:-cositas.domain.com-:cositas:error.html--:cositas:noaccess.html-5

-widgets.domain.com--:widgets:-widgets.domain.com-:widgets:errror.html--:widgets:noaccess.html-6

-www.domain.com--:widgets:-widgets.domain.com-:widgets:errror.html--:widgets:noaccess.html-7

192.168.0.2--:widgets:-widgets.domain.com-:widgets:errror.html--:widgets:noaccess.html-8

192.168.0.3--:kkn:-knickknacks.domain.com-:kkn:error.html--:kkin:noaccess.html-9

Editing the Virtual Hosts Settings File

The file itself is a text file, and you can edit it if you are careful. Be sure to back up the Virtual Hosts file before editing it.

If you change this file, the WebSTAR Virtual Hosts Plug-In will read the new data when the server starts up. If the data is not entered in the correct format, it may ignore your virtual host settings. Always check the server status window on startup and use the Admin to verify your Virtual Host settings.

The WebSTAR Virtual Hosts Plug-In will only read this file when the server starts up. After editing the file, quit and restart the server.


Manual Contents | Chapter Contents | Previous Page | Next Page