Implementation of virtual domain name under NT

Source: Internet
Author: User
Tags iis implement join log new features domain
Virtual domain name is actually a kind of virtual host.
The advent of virtual hosts is to save hardware investment. If the ISP uses a separate machine for each user who has applied for a domain name, it is obvious that the cost will be
High, and is also a waste for sites that are not frequently visited. So it appears everyone common a machine, but each user is independent of each other, work
Can be completely equated with owning your own host.

The virtual host is divided into two types based on IP address (ip-based) and name based (name-based).

Virtual host based on IP address everyone although on the same machine, or to each domain name to configure a separate IP address, so it seems not to be a
Kind of a good plan. Is there a machine, an IP address, and the ability to implement a separate domain name?

The idea was realized with the advent of the http/1.1 protocol. Its principle is to use the WEB server and browser together to achieve the virtual domain name and
corresponding directory or site corresponding. This allows users to enter a different name in the browser, although the DNS server is resolved by the same IP, but it is
Different content. It looks like two separate domain names. So this name-based virtual host is also known as a non-ip (non-IP). This also has a
Useful, you can give a very long URL a good memory and meaningful alias. This is the virtual domain name.

There are two areas of support for implementing virtual domain names:

One is the WEB server:

There are now a number of WEB servers that support a virtual host based on names. Like Netscape, IIS, etc. are supported. Of course the most used is Apache
Web server because it is easily configured or free, and it is the first server product to implement a virtual host based on name.

The second is the user's browser:

I think most of you should be using more than 3.0 version of IE or Netscape, then there is no problem, they are supported.

Now let's take a look at how to implement the virtual domain name under NT:

The first step is to get the DNS server to know the domain name you want to add, that is, to interpret it as a corresponding IP address. Because we're going to rely on the WEB server to differentiate
Domain name, so this IP address is naturally managed by your Web Server.

All you have to do is add an alias record to the DNS service, assuming you want to add aaa.domain.com, and you want to point to www.domain.com,
Can be written as:

AAA in CNAME www.domain.com.

You might think that if I want to add a lot of domain names, it is not very cumbersome, and the DNS server log files are very large. All right, let's fool DNS.
Server, change "AAA" to "*", so that it takes all the records that are not set to the end of domain.com to the www.domain.com
Go, whether it's aaa.domain.com or bbb.domain.com. This does not affect existing records.

The next step is to configure the Web server. We chose two common: IIS and Apache for NT.

First, IIS (remember that only version 4.0 supports a virtual host based on names.) )

Enter the IIS Service Manager, select the new Web site on the appropriate server, give the site a name and choose a good IP address (that is, the front
Good for the DNS server to point to. Select a good home directory path, if it is mapped to the remote URL, you can set a temporary path.

When you are finished, go to the properties of the new Web site, and click "Advanced ..." in the "Web Site" tab. button, edit the identity record, in the host header
Name "To fill in the virtual domain name to join, such as: aaa.domain.com, remember to fill in the complete, can not play AAA. Now you can go to the "Home directory" tab.
Select the specific directory to map, can be the machine or the local network on the machine path, but also the URL of the remote site.

IIS is intuitive to configure, but it is not appropriate to have a large number of records and is not suitable for online applications.

Second, Apache (new version has started to support NT, you can go to http://www.apache.org to get the latest version, and with the source code, there are
Interest can develop some new features yourself)

Configuring Apache needs to deal with profile http.conf, by default it is located in/program Files/apache group/apache/conf
Recorded.

First you need to join Namevirtualhost xxx.xxx.xxx.xxx

Where xxx.xxx.xxx.xxx is your virtual server IP address, which is the example above www.domain.com IP address. Here you can configure multiple
Virtual IP address. (Note: Here to use the IP address, do not use the domain name)

Next, add the records for each virtual domain: ... xxx.xxx.xxx.xxx to be consistent with namevirtualhost. Between two flags can be added
The configuration parameters are:
ServerName after you want to add the virtual domain name, such as aaa.domain.com;
DocumentRoot If you map to the local path is added to the back, such as "f:/html/aaa" (need to add double quotes);
redirect If you map to the remote URL can be added to the back, there are two parameters, the first is the relative path of the virtual domain name, the second is the remote site
The URL;
Serveralias can be added to the domain name alias, you can use wildcard characters, such as:
*.aaa.domain.com.

Here are a few examples:

1. Physical path mapped to this machine:

< VirtualHost xxx.xxx.xxx.xxx>
DocumentRoot "F:/program files/apache group/apache/htdocs/test"
ServerName test.domain.com
< virtualhost>

2. URLs mapped to the remote:
< VirtualHost xxx.xxx.xxx.xxx>
ServerName test1.doamin.com
Redirect/http://test.domain1.com/welcome.htm
</virtualhost>

Of course, there are many parameters, such as the location of log files, timeout settings, buffer settings, etc., you can refer to the Apache online Help file. per increase
Adding a virtual domain name increases the configuration code between the < virtualhost...>...</virtualhost> and is only restarted
The new configuration will take effect after Apache.

Obviously if you want to configure a large number of records will greatly increase the length of the configuration file, this will also make the Apache startup slow, occupy more memory, and also
Online applications are not easy to implement. You can configure the virtual host by selecting dynamic mode. So you don't have to write the configuration in advance, but by writing certain dynamic rules
From a dynamic build or to read information from a stand-alone configuration file at any time. This uses Apache's mod_rewrite module, so to add a
Yes:
LoadModule Rewrite_module Modules/apachemodulerewrite.dll

You can set up a number of rules to rewrite URLs, such as using environment variables, HTTP protocol headers, and even external databases to maintain URLs. It's work
Can be very powerful, but also bring complexity, you have to continue to explore and experiment to really grasp it, but it is worth it.

Finally, a simple introduction to the online free domain name a realization:

1. Maintain a user database through Perl to manage user additions, deletions, validations, and password changes.

2. A configuration file that uses Perl to maintain a separate virtual domain name through a database, such as: Vdomains.map, as follows:

Aaa.domain.com HTTP://WWW.DOMAIN1.COM/~AAA

Bbb.domain.com http://www.domain2.com/~bbb ...

3. Finally configure the httpd.conf file.
Open the rewrite module with Rewriteengine on, and use Rewritemap to set the location and attributes of the configuration file, using Rewritecond and
Rewriterule the corresponding rules can be established.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.