Virtual hosting, or subhosting, is one of the most
powerful features of the VPS v2 Virtual Server system. With virtual hosting, you can
support multiple domain names on a single VPS v2 Virtual Server. In other words, with virtual
hosting, you can host http://www.abc.com and http://www.xyz.com on the same VPS v2 Virtual Server,
each with its own domain name. You can give each virtual host the following
unique characteristics:
-
Its own unique login for SSH, Telnet, and FTP login
-
Access to its /home directory
-
E-mail addresses with its own domain name
Virtual hosting, or subhosting, is a great feature of VPS v2 Virtual Server system. However, there are some limitations to this capability
that you should understand. These limitations include the following:
HTTP/1.1-Compliance
The VPS v2 Virtual Servers use HTTP/1.1, which makes subhosting a
reality. However, to view subhosts you must have a browser that is
HTTP/1.1-compliant. Generally speaking, subhosts are supported by Netscape
Navigator 2.0+ and Microsoft Internet Explorer 3.0+. Any other browser that is
HTTP/1.1-compliant is also able to access virtual subhosted servers.
If your clients use an older browser that is not
HTTP/1.1-compliant, they are unable to view their sites or other sites that use
virtual subhosting.
Resource Allocation
A VPS v2 Virtual Server is capable of handling 30,000 to 50,000 hits per
day (assuming hits generally request about 5 Kbytes of data). This number
represents requests (hits) for files. If you have five subhosted domain names,
each trying to accommodate 10,000 hits per day (which really is not that much
if you have a graphically intensive page; one request for a .gif or .jpeg file
equals one hit), there is likely to be a slowdown that affects all subhosts on
the VPS v2 Virtual Server.
When a slowdown occurs, the VPS v2 Virtual Server administrative user
should reduce the number of subhosts on the VPS v2 Virtual Server by doing the following:
-
Upgrading one of the especially high traffic virtual hosted sites
to its own VPS v2 Virtual Server
-
Moving some subhosts to a less busy VPS v2 Virtual Server
-
Administrative users with a feel for serious virtual subhosting
can allocate resources in a fair and equitable way. A VPS v2 Virtual Server can only host a
finite number of virtual hosts.
A Shared IP Address
Virtual subhosting uses the resources of a single VPS v2 Virtual Server to
accommodate the needs of multiple Web sites. Among the resources that are
shared is the single IP address that is associated with the VPS v2 Virtual Server. Search engine
"spiders" that are not HTTP/1.1-compliant are unable to index these
sites. However, most major spiders and search engines are now
HTTP/1.1-compliant.
A VPS v2 Virtual Server can only support a single secure digital
certificate. This makes the use of SSL difficult, since all subhosts must use
the same secure digital certificate, and only one domain name can be associated
with a secure digital certificate. See Chapter 6 for more information.
Subhosted User access
Subhosted users can access the VPS v2 Virtual Server in several ways,
including:
-
Shell access
-
FTP
-
E-mail
-
iManager
-
FrontPage 2002
E-mail Limitations
The VPS v2 Virtual Server has only one IP address, so all mail sent to the
users on your server routes to that IP. When messages arrive for
webmaster@grizzles.biz and webmaster@someFamily.org, the VPS v2 Virtual Server views these as the
same address because both domains resolve to the same IP address:
webmaster@123.456.789.10.
We developed a way to get around this
limitation by using virtmaps. Messages for webmaster@grizzles.biz and
webmaster@someFamily.org, require that you configure the /etc/mail/virtusertable file in any of several
forms listed in the /etc/mail/virtusertable.sample
file, so that each message is delivered to the correct Webmaster.
See “Virtmaps” for more information.
Security Risks
It is important to consider some of the security issues
that relate to virtual subhosting. Take care to insure that CGI scripts are run
with proper ownership, and that file access is allowed only to the proper
users.
For example, the user directive can be used inside a
VirtualHost block to cause all CGIs for that subhost to run with access
privileges of a specified user. This would restrict the user from running a CGI
script that would modify or remove files belonging to another sub-hosted user.
It is also important when setting up new subhosted
accounts, to associate the domain name (or Virtual Host, in Apache terms) with
a real user account on your system. This user account might be the name of the
administrator (added with pw, or vadduser, for example), or it might be the
generic 'vhost' user (which vaddhost creates the first time you run it without
specifying a user).
By segregating your subhosted account in this way, you
insulate yourself and the other accounts that might be hosted on your VPS v2 Virtual Server,
from one another.
Providing stock CGI scripts in a directory you control
Most Web sites do not demand a great deal of custom CGI
programming. It is probable that you can provide a library of stock CGI scripts
that will meet the needs of the subhosted users. A sample composition of such a
library might include a counter, a guestbook, and a generic form processor.
-
Store these scripts in the virtual host’s (subhost’s) cgi-bin directory,
which will probably be located at /usr/local/apache/cgi-bin/
-
Configure each of your virtual hosts (subhosts) to use this cgi-bin
directory by editing the /www/conf/httpd.conf
file and adding the following line to their own specific <VirtualHost>
definitions:
ScriptAlias /cgi-bin/ /home/username/www/cgi-bin
If you are designing Web content and writing custom CGI
scripts in addition to providing your clients with hosting service, then this
discussion is not applicable to your specific situation. Still, it is something
to remember if you later decide to expand the scope of your services.
Adding a Virtual Host (Subhost) using iManager
To add a virtual host using iManager:
-
-
-
In iManager, click Tools and Wizards,
and beside Virtual Hosts, click Add. The
Virtual Host form appears displaying descriptions and instructions for
completing the form on the lower portion of the form.
-
Host Name (example: grizzles.biz)
-
Server Name (example: grizzles.biz)
-
Server Administrator (example: bob)
-
Document Root (example: /home/bob/www/grizzles.biz)
-
Script Alias (example: /home/bob/usr/local/apache/cgi-bin)
-
TransferLog (example: /usr/local/apache/bob/domain-access_log)
-
ErrorLog (example: /usr/local/apache/bob/domain-error_log)
-
Other Directives (optional)
-
Placement in httpd.conf (Default is to append the virtual host
entry to the end of the file.)
-
You can choose to click Populate Virtual Host Directives from
Template, as described on the screen, just above the form.
-
Click Submit.
Subhost information submitted in
this step automatically updates the /www/conf/httpd.conf
file.
-
Create virtmaps to prevent misdirection of mail. The VPS v2 Virtual Server has only one
IP address, so all mail sent to the users on your server routes to that IP.
Messages for webmaster@grizzles.biz and
webmaster@someFamily.org, require that you configure the /etc/mail/virtusertable file in any of several
forms listed in the /etc/mail/virtusertable.sample
file, so that each message is delivered to the correct Webmaster.
Note: All log files
are owned by root and count against his quota. Subhosts can only view the log
files and cannot modify them. To change ownership of the log files type the
following at the command prompt as root:
% chown username:groupname logfile
Adding a Virtual Host (Subhost) using vaddhost
To add a virtual host using by the vaddhost command:
-
Connect to your VPS v2 Virtual Server using SSH and add the individual users of the
subhosted domain. ( See “Creating New Users” )
-
-
Connect to your VPS v2 Virtual Server using SSH and type vaddhost.
-
Proceed through the script, supplying the following information. Press Enter to accept the [default values].
-
The user who is to be associated with the virtual host (subhosted
domain). (Example: bob)
-
Type
y or press Enter
if the information is correct.
-
Type the hostname (example: grizzles.com) and press Enter.
-
Type
www. and the same domain name you just
typed, and press Enter. (example:
www.grizzles.com)
-
Press Enter once more to move to
the next step.
-
Type y or press Enter if the hostname information is correct.
-
Type
the e-mail address of the Web site administrator and press Enter. The default value is webmaster@domain.name.
If accepted, the e-mail address of the Web site administrator becomes
webmaster@grizzles.com.
Heed the information message at this important side step. After the virtual
host has been added, add an entry to the virtusertable
file by:
-
Start another shell session in a different window and cd to /etc/mail.
-
Edit the virtusertable by adding an entry in the form of:
alias@email.address user
(example: webmaster@grizzles.com bob)
-
Save and close the virtusertable
file.
-
Type make to rebuild the database.
Likewise, make will generate a new sendmail.cf file if there are changes to the sendmail.mc file, and then it will restart
Sendmail.
-
Type makemap hash /etc/mail/virtusertable <
/etc/mail/virtusertable to rebuild the access database only.
-
Press
Enter, then type the document root for
this user. (example: /home/joe/www/grizzles.biz)
-
Press Enter to create the
directory.
-
Press Enter or type y if the information is correct.
-
Select a location for the transfer logs.
-
Press Enter or type y if the information is correct.
-
Select
a location for the error logs.
-
Press
Enter or type y if the information is correct.
-
Select
an option for CGI execution for this virtual host.
-
Press
Enter or type y if the information is correct.
-
Review
the virtual host entry, and Press Enter or
type y if the information is correct.
Adding a Virtual Host (Subhost) in /www/conf/httpd.conf
To add a virtual host by editing the httpd.conf file:
-
Connect to your VPS v2 Virtual Serverusing SSH and add the associated user of the
subhosted domain. See Creating New Users
-
-
Connect to your VPS v2 Virtual Server and go to /www/conf.
-
Edit the httpd.conf file by adding the <VirtualHost> block with
your own information, following the example of:
<VirtualHost IP:80>
User username
Group groupname
ServerName domain.ext
ServerAdmin username@domain.ext
DocumentRoot /home/username/www/domain.ext
ScriptAlias /cgi-bin/
"/home/username/www/cgi-bin/"
<Directory /home/username/www/cgi-bin>
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
ErrorLog
/home/username/www/logs/domain.ext-error_log
CustomLog
/home/username/www/logs/domain.ext-access_log combined
</VirtualHost>Type
-
Type:
% restart apache
-
Create virtmaps to prevent misdirection of mail. The VPS v2 Virtual Server has only one
IP address, so all mail sent to the users on your server routes to that IP.
Messages for webmaster@grizzles.com and
webmaster@someFamily.org, require that you configure the /etc/mail/virtusertable file in any of several
forms listed in the /etc/mail/virtusertable.sample
file, so that each message is delivered to the correct Webmaster.
See Virtual Address Mappings.
Setting up Additional Options for Virtual Hosts (example)
The following example displays lines that set an
additional option such as the script alias:
# point mark.com to subdirectory mark
<VirtualHost 128.121.60.86:80>
SSLDisable
User mark
Group mark
ServerName mark.com
ServerAlias www.mark.com
ServerAdmin webmaster@mark.com
DocumentRoot /home/mark/www/mark.com
ScriptAlias /cgi-bin/
"/home/mark/www/cgi-bin/"
<Directory /home/mark/www/cgi-bin>
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
CustomLog
/usr/local/apache/logs/mark/mark.com-access_log combined
ErrorLog /usr/local/apache/logs/mark/mark.com-error_log
</VirtualHost>
Maintenance
Server log files that record Web transactions are located
in /usr/local/apache/logs. You can clear the
log files, the access_log and the error_log, using either of the savelogs and
rotatelogs commands.
See "Web Logs” on for more information.
Important Commands, Directories, and Files
The following table describes commands, directories, and
files for managing the Web server.
|
Name |
Type |
Description |
|
/usr/local/
apache/bin/apachectl start |
command |
Starts Apache |
|
/usr/local/
apache/bin/apachectl start |
command |
Stops Apache |
|
restart_apache |
command |
Restarts Apache |
|
/usr/local/
apache/bin |
directory |
Apache utilities (machine readable binary files) |
|
/usr/local/
apache/conf |
directory |
Web server configuration files (httpd.conf and mime.types)
that define and control the behavior or your virtual Web service are stored
in the conf subdirectory. |
|
/usr/local/
apache/icons |
directory |
Contains several graphical icons that are used when a
directory listing is shown to a browser client. Several default icons are
included in this directory. |
|
/usr/local/
apache/libexec |
directory |
Apache library files and modules |
|
/usr/local/
apache/man |
directory |
Apache manual pages |
|
/usr/local/
apache/proxy |
directory |
Proxy server |
|
/usr/local/
apache/cgi-bin |
directory |
The default directory for CGI scripts. |
|
/usr/local/
apache/htdocs |
directory
(document root) |
Contains the Web files for the primary domain’s Web site;
the document root for the primary domain. |
|
/home/username/
www/subhosted_domain.name |
directory
(document root) |
Suggested directory for a subhost’s Web files. The
document root for that specific subhost (virtual host). |
|
/usr/local/
apache/include |
directory |
Apache include (header) files |
|
/usr/local/
apache/logs |
directory |
Detailed logs of which Web files are requested and by
whom. |
|
/usr/local/
apache/modules
(symlink to libexec) |
directory |
Modules that can be added dynamically to your apache Web
server. Refer to the “Modules” section for more information. |
|
/www |
symlink |
Shortcut to /usr/local/apache |
|
/home/username/
www/domain |
directory |
Suggested user home directory.
(If used, this pathname becomes the subhost’s document root.) |
|
/home/enetrics/www/enetrics.com/
username |
directory |
Alternate user home directory. |
|
/www/conf/httpd.conf |
file |
The configuration file that contains the virtual host
(subhost) entries |
|
/www/conf/httpsd.conf |
file |
A virtual symlink to httpd.conf. You can edit either
httpd.conf or httpsd.conf, and the edited file will update the other. |
|
/www/conf/mime.
types |
file |
MIME stands for Multimedia Internet Mail Extensions. This
file contains a list of the file extensions Apache knows about. You can add
more types to it. |
For More Information
For more information about the topics discussed in this
chapter, see the following pages on the Enetrics Communications Web site.
Refer to the document entitled "Web Publishing Using
HTTP PUT."
Understanding Virtual Hosting
Virtual Subhosting
|