Configuring the Apache server reverse proxy using XAMPP

Source: Internet
Author: User

Timor-m 2018-6-17 11:58:03
Preface

The reverse proxy method refers to a proxy server that accepts connection requests on the Internet, 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, Reverse. At this point the proxy server appears as a reverse proxy server externally.

In layman's terms, because the processing of a single server client (user) Request ability has a limit, when the user's access requests rushed into the situation, will cause the server is not busy, you can use multiple servers to share the thousands of user requests, when the proxy server received a Web request, Can be assigned to the server processing the specified task, or idle server processing, so that the speed of service-side processing is improved, of course, the use of proxy server more, such as Ajax cross-domain, server security, etc. need to be understood by the reader.

, the reverse proxy is shown:

If you want to configure the reverse proxy server, I believe many people will prefer nginx (many online posts), then we will today talk about using XAMPP built in the local test environment of the Apache configuration.

For this configuration demo, we need to configure several virtual servers (virtual hosts):
    1. ABC.com
    2. Lby.com
    3. Web.com

Finish configuring the final effect:

We can use the 127.0.0.1 (localhost) address directly to access the contents of the three domains under the domain name agent.

For example: Now we need to access lby.com, we can use 127.0.0.1/lby to access

This configuration is divided into two parts: first, configure the local hosts domain name resolution.

Because it is the domain name of the virtual host, so the DNS domain name cannot be resolved, local access, we can first configure a local resolution for easy access, the distance configuration is as follows:

Found in the System C Drive directory: C:\Windows\System32\drivers\etc\hosts file

After opening the file, append the following configuration to the last face:

127.0.0.1   lby.com
  ABC.com
  Web.com

Note: Sometimes it is not possible to save, because the C drive file is read-only and cannot be changed, so you need to set permissions to allow modification.

Second, configure the virtual hosts and agents in Apache. The above already has the domain name configuration, then starts to build the above 3 virtual hosts: 1. Open Htdocs in the Xampp folder (the secondary folder is the site root of the XAMPP server by default):

For convenience, create the following 3 folders under this folder to be used as the directory for the virtual host:

First one: Lby

Second one: ABC

Third one: web

Reminder: In these three directories, you can set up a index.html page, set different content separately, in order to facilitate the identification of use.

2. Start configuring the virtual host:

Under the Xampp folder, locate the httpd-vhosts.conf (virtual host configuration file):

I:\xampp\apache\conf\extra\httpd-vhosts.conf

After opening, add the following configuration (added to the last side of the document):

Configure the first virtual host first: (lby.com)

<virtualhost *:80>
  ServerAdmin [email protected]
  documentroot "/xampp/htdocs/lby"
  ServerName lby.com
  errorlog "Logs/dummy-host2.example.com-error.log"
  customlog "Logs/dummy-host2.example.com-access.log" common
</VirtualHost>

Configure the second virtual host: (abc.com)

<virtualhost *:80>
  ServerAdmin [email protected]
  documentroot "/XAMPP/HTDOCS/ABC"
  ServerName abc.com
  errorlog "Logs/dummy-host2.example.com-error.log"
  customlog "Logs/dummy-host2.example.com-access.log" common
</VirtualHost>

Configure the third virtual host: (web.com)

<virtualhost *:80>
  ServerAdmin [email protected]
  documentroot "/xampp/htdocs/web"
  ServerName web.com
  errorlog "Logs/dummy-host2.example.com-error.log"
  customlog "Logs/dummy-host2.example.com-access.log" common
</VirtualHost>
Configure to this, you can open Apache server, test three domain name access, if no other problems should be able to access the normal! 3. Start configuring the Reverse proxy:

A. Find I:\xampp\apache\conf\httpd.conf

Set httpd.conf, turn on proxy:

The "#" in the configuration file represents the comment, so you just need to remove the comments from the following lines:

Line 139th: LoadModule proxy_module modules/mod_proxy.so
Line 142th: LoadModule proxy_connect_modulemodules/mod_proxy_connect.so
Line 145th: LoadModule proxy_ftp_modulemodules/mod_proxy_ftp.so
Line 147th: LoadModule proxy_http_modulemodules/mod_proxy_http.so

B. Configure the agent:

In fact, the configuration of the virtual host file (I:\xampp\apache\conf\extra\httpd-vhosts.conf), there is a default host is localhost, we look at its default configuration:

<virtualhost *:80>
  ServerAdmin [email protected]
  documentroot "/xampp/htdocs/"
  
  errorlog "Logs/dummy-host2.example.com-error.log"
  customlog "Logs/dummy-host2.example.com-access.log" common
</VirtualHost>

The above is the default 127.0.0.1 host configuration, so we have to configure on this host to proxy request we set up the virtual host, we need to add the following configuration:

<virtualhost *:80>
  ServerAdmin [email protected]
  documentroot "/xampp/htdocs/"
  ServerName localhost
    
  proxypass  /web  http://web.com/
  proxypass  /lby  http://lby.com/
  Proxypass  /ABC  
  errorlog "Logs/dummy-host2.example.com-error.log"
  customlog "Logs/dummy-host2.example.com-access.log" common
</VirtualHost>

At this point, after the configuration is saved, restart the Apache service

We can use 127.0.0.1/lby to visit the original virtual host lby.com content.

Configuring the Apache server reverse proxy using XAMPP

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.