Nginx-related functions and knowledge points

Source: Internet
Author: User

Nginx-related functions and knowledge points

Main functions of Nginx: 1. Reverse Proxy 2. Server Load balancer 3. HTTP server (including dynamic and static separation) 4. Forward proxy;

I. Reverse Proxy

A proxy server is used to receive connection requests from the Internet and then forward the requests to servers 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 reverse proxy server. Simply put, a real server cannot be directly accessed from the Internet. Therefore, a proxy server is required, and the proxy server can be accessed from the internet in the same network environment as the real server, of course, the same server may have different ports.

Ii. Five Load Balancing Methods for Nginx upstream (jump to load balancing through reverse proxy ):

1. Round Robin (RR): each request is distributed to different backend servers one by one in chronological order. If the backend servers are down, they can be automatically removed.

2. weight (weight): The weight is proportional to the access ratio. It is used when the backend server performance is uneven. If the backend server is down, it can be automatically removed. For example, the access volume of server A is twice that of server B.

3. ip_hash (Consistent hash): each request is allocated according to the hash result of the access ip address. In this way, each visitor accesses a backend server at a fixed time, which can solve the problem that the session cannot be cross-server, if the backend server is down, it must be down manually.

4. fair (a third-party plug-in): requests are distributed based on the response time of the backend server, and requests are prioritized when the response time is short.

5. url_hash (a third-party plug-in): requests are allocated based on the hash results of the access url so that each url is directed to the same backend server, which is effective when the backend server is the cache server. Add a hash statement to upstream. hash_method is the hash algorithm used.

The preceding five types of Server Load balancer instances are applicable to different scenarios. Therefore, you can select which policy model to use based on the actual situation.

Iii. HTTP static resource Server

Nginx is also a server with static resources. When only static resources are available, Nginx can be used as the server. At the same time, static and dynamic separation is also popular, which can be implemented through Nginx. When dynamic resource requests exist, they are forwarded to dynamic web servers to process dynamic resources.

4. Forward proxy

Is a server located between the client and the origin server. To obtain content from the origin server, the client sends a request to the proxy and specifies the target (the origin server ), then the proxy transfers the request to the original server and returns the obtained content to the client.

Reference resources:

Nginx Cluster load balancing configuration process detailed explanation http://www.linuxidc.com/Linux/2017-02/140549.htm

Nginx advanced application-load balancing and rewrite rule http://www.linuxidc.com/Linux/2017-02/140476.htm

Nginx simple implementation of website load balancing http://www.linuxidc.com/Linux/2017-02/140351.htm

Li Tong learned the difference between my forward proxy and reverse proxy. I did not really understand it. I found two pictures and understood the meaning of the two pictures. Thank you, Li.

Forward proxy

Reverse Proxy

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.