Nginx Proxy reverse Proxy and internal redirection

Source: Internet
Author: User
Tags sendfile

Nginx Proxy reverse Proxy and internal redirection


Nginx Proxy is the trump card function of Nginx, using proxy can basically achieve a complete 7-layer load balancing, it has these characteristics:
1, powerful, super performance, the bug does not work more stable.
2, back-end steering and business configuration separation, very flexible.
3, can specify any IP and port configuration, and the network environment is irrelevant.
4, can be for the back-end of the situation to judge, not normal to request another host, and automatically remove abnormal host.
5, can assign the weight, and distribute evenly.
6, can realize a variety of allocation strategy, can refer to: http://www.fengfly.com/plus/view-65277-1.html
7, can easily modify the Reponse and request header
8, upload files using asynchronous processing, Nginx will first receive the file, and then forward to the back end, which can reduce the back-end server many connections. can refer to:
Http://www.fengfly.com/plus/view-65268-1.html
9. Support GZIP Compression
10, can pass the request header, link, IP and so on all the input item carries on the forwarding.
11, Proxy caching function, is still relatively simple, looking forward to
12, get the client IP and forward to the background, compared with squid x_forwarded_for
13, background server can be returned by X-accel-redirect response header to control the download
14, on the implementation of the proxy error page jump
15, support the judgment expression, expecting the expression of the operation, so that the configuration file can become a language.


internal redirection: The request is redirected between the internal Web App server and transparent to the browser.

Sometimes you may need to implement a control download: a request to download a file is forwarded to a script, and then the script decides what to do: Send this file to the user, appear a Deny access page, or something else. The LIGHTTPD server can be implemented by returning a X-sendfile header from a script, while Nginx is implemented by using the X-accel-redirect header.

There are two main differences:

Header must contain URI
Location must be defined as internal; To prevent the client from accessing the URI directly


Http://wiki.nginx.org/NginxChsXSendfile


download control using Nginx's X-accel-redirect header (with PHP and Rails instances): http://bianbian.org/technology/154.html
Several methods of Nginx load Balancer processing session sharing: http://opensource.csdn.net/bbs/thread/621
Nginxhttpupstreamrequesthashmodule:http://wiki.nginx.org/nginxhttpupstreamrequesthashmodule
Nginx's upstream module provides good support for load balancing:
Nginx-upstream-jvm-route: The module that implements session sticky mainly according to cookie or URL http://deidara.blog.51cto.com/400447/193887

The advantage of the


Nginx
Nginx as an HTTP server has the following basic features:
1         processing of static files, index files, and automatic indexing ; Open file descriptor buffering.
2)         reverse proxy acceleration without caching, simple load balancing and fault tolerance.
3)         FastCGI, simple load balancing and fault tolerance.
4)         modular structure. Includes gzipping, byte ranges, chunked responses, and Ssi-filter et. If multiple SSI exists on a single page by a fastcgi or other proxy server, the processing can run in parallel without having to wait for each other.
5)         supports SSL and TLS SNI.

Nginx is developed for performance optimization, performance is its most important consideration, and implementation is highly efficient. It supports the kernel poll model, which can withstand high load, and reports indicate that it can support up to 50,000 concurrent connections. The
Nginx has a high stability. Other HTTP servers, when they encounter spikes in access, or when someone maliciously initiates a slow connection, are likely to cause the server to run out of physical memory for frequent swapping, losing response, and restarting the server. For example, when Apache is up to more than 200 processes at the moment, the Web response is significantly slower. Nginx has adopted a phased resource allocation technique, which makes its CPU and memory occupancy rate very low. Nginx officially maintains 10,000 inactive connections, which only account for 2.5M of memory, so attacks like DOS are essentially useless for nginx. As far as stability is concerned, nginx is better than lighthttpd. The
Nginx supports hot deployment. It's very easy to start, and it's almost 7*24 uninterrupted, even if it's running for a few months and doesn't need to be restarted. You will also be able to upgrade the software version with uninterrupted service. The
Nginx uses the Master-slave model to take advantage of the SMP and to reduce the blocking latency of worker processes on disk I/O. . When a Select ()/poll () invocation is used, you can also limit the number of connections per process. The
Nginx code is very high quality, code is very standard, the technique is mature, module expands is also very easy. Particularly worth mentioning is the powerful upstream and the filter chain. Upstream provides a good basis for writing such as reverse proxy and other server communication modules. And the coolest part of the filter chain is that each filter does not have to wait for the previous filter to finish executing. It can make the output of the previous filter the input of the current filter, which is a bit like a Unix pipeline. This means that a module can begin compressing requests sent from a back-end server and can transfer the compression to the client before the module receives the entire request from the backend server. The
Nginx employs some of the latest features provided by the OS, such as support for Sendfile (Linux 2.2+), Accept-filter (FreeBSD 4.1+), Tcp_defer_accept (Linux 2.4+), Thus greatly improving the performance

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.