Nginx Configuration Reverse proxy (Apache+nginx)

Source: Internet
Author: User
Tags nginx server

Nginx because of its efficient concurrency processing ability, and began to be more and more people accept and recognition, now many sites have been completely with nginx instead of Apache to deal with static pages, but dynamic pages, Apache still has its own unique.


Here's what the reverse proxy is, and why it's a reverse proxy. According to the encyclopedia, the reverse proxy (Reverse proxy) method refers to the proxy server to accept the connection request on the Internet, and then forwards the request to the server on the internal network. and returns the results from the server to the client requesting connections on the Internet , at which point the proxy server behaves as a server. Concise point, according to my understanding, the reverse proxy is a server responsible for receiving external network requests, but not processing, but to tell other intranet server to deal with, and the results of their processing returned to the user. From the user's point of view, the request is the proxy server to handle, in fact, he is forwarded a bit, return the results of others.


So what is the role of a reverse proxy? As the encyclopedia says:

You can provide an encrypted connection from the external Proxy Server on the firewall to the internal Secure Content server on the firewall. you can allow clients to securely connect to a proxy server, which facilitates the secure transfer of information, such as credit card numbers. A secure reverse proxy causes each secure connection to become slower due to the overhead involved in encrypting the data. However, because SSL provides a caching mechanism, both sides of the connection can reuse previously negotiated security parameters, greatly reducing the overhead of subsequent connections. It is said to be easy to understand: one is security, the other is to increase the cost of the system to a certain extent.
here is how to do reverse proxy, here is an example, interested in you can test yourself.
first install Nginx and bind to 80 port, install Apache bound listening 8080 port. Then set the Nginx Server directory for the Www_nginx,apache server directory as Www_apache, respectively, in 2 directories to create a new index.html file, which is written in the Nginx,apache2 word is sufficient. then we configure the Nginx configuration file, generally nginx.conf this file, modify the configuration information inside. Location /{ proxy_pass 127.0.0.1:8080;}at the same time to start Nginx and Apache, visit 127.0.0.1, you will find a magical thing, altogether output Apache, obviously nginx server directory there is no output, but Apache, that is because Nginx has a reverse proxy, Go to Apache to listen for the 8080 port to content, and then Apache returned to his processed results. This is a simple example, in fact, we can let Nginx handle static pages, processing images, CSS, JS and other files, and let Apache handle dynamic files. For example, we can modify this:

Location ~ \.php$ {

Proxy_pass 127.0.0.1:8080;

}

This is only PHP files to the Apache processing, the other is nginx to deal with.

Nginx Configuration Reverse proxy (Apache+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.