Cloud host environment set up a course to build the Universal mainframe

Source: Internet
Author: User
Tags add header iis mysql php and versions access port number

Many owners in the purchase of virtual host, will look at the virtual host some of the parameters, the most important is the support of the program language. Now many IDC businesses are claiming the almighty host.

The most funny thing is that I just built the station, the purchase of a small domestic host (called the host House) of the virtual host, their publicity is the universal host, what language are supported. Such a pretence to cheat some rookie also can, for a understand technology, can only to their trick cast to despise the vision. Later asked to know what they call the almighty host, but only to support PHP and ASP running simultaneously (using IIS to run PHP), Even asp.net do not support, for this matter, the author also and their theory for a long time, now estimated no longer dare to claim the almighty host, such a businessman, hope that all stationmaster can be far away, too immoral.

First of all, say, what is the almighty host.

The so-called universal host, is a server above the same time to support a number of different application server running, and can be accessed through the external independent domain name of the host. There are more than one, at least greater than or equal to three.

For now, Apache,iis,tomcat is currently widely used in three Web server software, where Apache,tomcat is open source software, not only for Unix systems, but also for Win32 platform based versions.

IIS is a self-contained component of the Windows operating system, and also provides powerful Internet and intranet service features. These three kinds of server software are unique, IIS for asp+access support is better, and Apache is the Php+mysql platform is the choice, Tomcat is running the Java language Program server.

As you all know, HTTP has only one open port, which is 80 ports. External access to the site through the independent domain name, if not port, will be the default access to the server 80 ports below the Web site. Realistically, these application servers cannot use only one port. If you want to access, you must use the domain name plus port number to access, which is obviously not conducive to promotion. Therefore, we need to find ways to allow users to enter a simple domain name, and we intercept the domain name in the background, and then dynamically resolved to different port sites.

In this way, I think of a lot of ways, the traditional is to reconfigure IIS, so that it supports PHP+MYSQL, or reconfigure Apache so that it can support asp+access. However, considering these two methods can be achieved from the technical, but the configuration process is more complex, not easy to promote, not conducive to the use of beginners. And if you build a Java program, it's even more complicated.

The author has not been engaged in the work of IDC industry, there is no experience in this area. At the same time thinking about how the Almighty function is now achieved. According to the author's experience, they are a 80-port server to do agent distribution, the different domain name distribution to the unused application server site.

Through this idea, the author thought of the use of Apache virtual host function and reverse proxy module to achieve.

What is Apache virtual host. This is defined on the website of Apache's official technology.

A virtual host refers to running multiple Web sites (such as www.company1.com and www.company2.com) on a single machine. A virtual host can be "ip-based", that is, one site per IP, or "Based on name", that is, multiple sites per IP. The fact that these sites run on the same physical server is not clearly disclosed to end users.

Apache is the first server to support ip-based virtual hosts. Apache version 1.1 and newer versions support both ip-based and name-based virtual hosts. A name-based virtual host is sometimes called a host-based or non-IP virtual host.

Detailed Address: http://httpd.apache.org/docs/2.2/vhosts/Note: This article is a virtual host configuration based on name.

What is a reverse proxy.

A reverse proxy (Reverse proxy) means that a proxy server accepts a connection request on the Internet and then forwards the request to a server on the internal network and returns the results from the server to the client requesting the connection on the Internet, At this point, the proxy server behaves as a Web server.

So we'll use the Apache server as a proxy Web server that handles any requests from outside and returns to the outside.

Interested friends can learn what a forward agent is.

The term is probably finished, then this article mainly through an example to give you a brief description of the specific configuration methods.

Preface: Still take the author's www.bxw001.com this domain name as an example. This site is a asp+access site, built under IIS6.0, with Port set to 81. If the reverse proxy is not used, the user must use WWW.BXW001.COM:81 to access the site, it is troublesome.

After the reverse proxy setting, the user still uses the www.bxw001.com domain name website, but first enters the Apache server, then transfers to the official website under IIS.

Set the steps as follows:

1, loading Apache proxy module

Open the httpd.conf file, let go of the following lines of code comments, (the previous # can be removed), at this time Apache is a Web proxy server.

LoadModule Proxy_module modules/mod_proxy.so
LoadModule Proxy_connect_module modules/mod_proxy_connect.so
LoadModule Proxy_http_module modules/mod_proxy_http.so
LoadModule Proxy_ftp_module modules/mod_proxy_ftp.so

2, set up a virtual host, port redirection

To create a virtual host for the Web site that requires the agent, I strongly recommend that you configure it individually through a virtual host. Some friends may be directly in the httpd.conf file to modify, so although it can be achieved, but all access, including not the proxy domain name access will go to the agency's website.

Because the order in which the Apache virtual hosts are loaded is loaded sequentially, if the URL that is accessed is configured with a virtual host, proxy access is performed, and if not, the default is the first.

Therefore, it is necessary to introduce a separate configuration file for the virtual host, where the virtual host configuration is increased.

Find this line of code in the httpd.conf file, Include conf/extra/httpd-vhosts.conf, and remove the # annotation.

The following configuration of the virtual host is performed under Httpd-vhosts.conf.

The default Apache provides two examples, not the tube, directly commented out, or modified on the original can be.

We are going to turn all access to the site www.bxw001.com domain name to 81 ports under IIS, adding a virtual host first. The code is as follows:

<virtualhost *:80>
ServerAdmin [email protected]
DocumentRoot "D:/wwwroot/www.bxw.com"
ServerName bxw001.com
Serveralias www.bxw001.com
ErrorLog "Logs/bxw001.com.log"
Customlog "Logs/bxw001.com.log" common
<directory "D:/wwwroot/www.bxw.com" >
Require all granted
</Directory>
proxypass/http://localhost:81/
proxypassreverse/http://localhost:81/
</VirtualHost>

Explain:

ServerAdmin: This is the mailbox, you can default
DocumentRoot: This is the root directory address of the website you are being represented on. This is the ASP Web site directory below IIS6.0. Note the direction of the directory slash.
ServerName: The domain name of the agent, here is the independent domain name of the ASP website under your IIS.
Serveralias: Ditto, alias, generally can be written as a level or level two domain name.
ErrorLog: Log file address and name. Generally the domain name as a file name, convenient to distinguish, by default stored in the Apache logs directory.
<directory > Set access permissions for the directory of the virtual host. I suggest that the permissions are set under the virtual host alone, rather than in the httpd.conf unified set into all can be accessed, this is not safe.
Proxypass: This is the key, which means that the real access address of the ASP website below IIS, written in localhost, can also be written as a domain name + port, which depends on the host header address you set up in IIS. If the host header defaults, then this is localhost.
Proxypassreverse: Reverse proxy address, return the information to the user.

Also, do not forget to add the default virtual host configuration at the beginning of all virtual hosts.

<virtualhost *:80>
ServerAdmin [email protected]
DocumentRoot "D:/wamp/www"
ServerName localhost
Serveralias localhost
<directory "D:/wamp/www" >
Options FollowSymLinks
AllowOverride All
Order Allow,deny
Allow from all
</Directory>
</VirtualHost>

This default, you can set to Apache's www directory.

After the two steps are completed, restart the Apache service after saving. You can try to access the ASP website domain name www.bxw001.com, do not add the port number, to see whether the normal access. Oh.

If you want to add more than one IIS Web site or Java site, simply add the virtual host by following the code in step 2 above, and write the proxy domain name as the URL of the website you want to be represented in.

Through this operation, you can achieve a perfect universal host, you can arbitrarily in the server to build a number of different environments of the site.

Source: Sixdosoft submission.



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.