Nginx configuration reverse proxy (Apache + nginx)

Source: Internet
Author: User
Tags nginx server

Nginx configuration reverse proxy (Apache + nginx)

Due to its efficient concurrent processing capability, nginx has been accepted and recognized by more and more people. Many websites now use nginx instead of apache to process static pages. However, in terms of dynamic pages, apache has its own uniqueness.

The following describes what is a reverse proxy and why it is a reverse proxy. According to the introduction in Encyclopedia: the Reverse Proxy (Reverse Proxy) method is to accept connection requests on the internet by Proxy server, and then forward the requests to the server on the internal network, return the result obtained from the server to the Client Requesting connection from the internet. The proxy server is displayed as a server. In my understanding, the reverse proxy is a server that is responsible for receiving requests from the Internet, but does not process the requests by itself. Instead, it tells other Intranet servers to process the requests, and return the processing result to the user. From the user's point of view, the request is handled by the proxy server. In fact, the proxy server forwards the request and returns the results of others.

So what is the role of reverse proxy? According to the Encyclopedia:

Provides encrypted connections from the external proxy server of the firewall to the Internal Security content server of the firewall. Allows clients to Securely connect to the proxy server, facilitating secure transmission of information (such as credit card numbers ). The security reverse proxy slows down the system overhead of each security connection due to data encryption. However, because SSL provides a high-speed cache mechanism, the connected parties can reuse the previously negotiated security parameters to greatly reduce the system overhead of subsequent connections. Security is easy to understand. First, system overhead is improved to a certain extent.
The following describes how to perform reverse proxy. Here is an example for everyone. If you are interested, you can test it yourself.
Install nginx and bind it to port 80. install apache and bind it to listening to port 8080. The deployment file, which contains nginx and apache. Then we can modify the configuration information in the nginx configuration file, which is generally nginx. conf. Location/{proxy_pass 127.0.0.1: 8080;} start nginx and apache at the same time. When accessing 127.0.0.1, you will find a magic thing, and output apache at all, it is clear that there is no output in the nginx server directory, but apache, because nginx performs a reverse proxy, go to the apache listening port 8080 for content, and then apache returns the result to him after processing. This is a simple example. In reality, we can let nginx process static pages, images, css, js, and other files, while apache can process dynamic files. For example, we can modify it as follows:

Location ~ \. Php $ {

Proxy_pass 127.0.0.1: 8080;

}

In this way, only PHP files are handed over to apache for processing, while other files are handled by nginx.

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.