1. Background introduction
Nginx (engine x) is a high-performance HTTP and reverse proxy server , Nginx is a lightweight web server/reverse proxy server and email proxy server. Its characteristics are that it occupies less memory and has strong concurrency capabilities. In fact, nginx’s concurrency capabilities do perform better among web servers of the same type. Users of nginx websites in mainland China include: Baidu, JD.com, Sina, NetEase, Tencent, Taobao, etc.
2. Knowledge analysis
1. Proxy server
Generally refers to the machine inside the LAN sending requests to the server on the Internet through the proxy server. The proxy server generally acts on the client end. A complete proxy request process is: the client first creates a connection with the proxy server, and then requests to create a connection to the target server or obtain the specified resources of the target server according to the proxy protocol used by the proxy server. Web proxy (proxy) server is the intermediate entity of the network. The proxy is located between the web client and the web server, playing the role of "middleman". The HTTP proxy server is both a Web server and a Web client.
2. Forward proxy
The forward proxy is a server between the client and the origin server. In order to obtain content from the origin server, the client sends a Request and specify the target (origin server), then the proxy forwards the request to the origin server and returns the obtained content to the client. The client must make some special settings to use the forward proxy.
3. Reverse proxy
Reverse proxy In the computer world, there is a limit to the ability of a single server to handle client (user) requests. When user access requests flood in, Sometimes, it will cause the server to be overwhelmed. Multiple servers can be used to share thousands of user requests. These servers provide the same service, and users will not feel any difference at all. The server accepts the client's request, then distributes the request to a specific server for processing, and then feeds the server's response back to the client.
4. Implementation of reverse proxy
1) A load balancing device is required to distribute user requests and distribute user requests to idle servers;
2) The server returns its own services to the load balancing device;
3) The load balancing returns the server's services to the user;
3. Frequently Asked Questions
1. Forward proxy and reverse proxy What is the difference between reverse proxy
2. Why use reverse proxy
4. Solution
Answer: 1. The difference between the two is that the objects of the proxy are different: The object represented by the proxy is the client, and the object represented by the reverse proxy is the server.
Answer: 2. Facilitate server distribution and expansion. In practice, there is a limit to the ability of a single server to handle client requests. When the number of requests is too large, the server will be too busy. Therefore, multiple servers are used to share the user's request processing. These servers provide the same service. For users, no difference. Then a load balancing device is needed to distribute user requests to idle servers, and then the server returns the results to the load balancing device, and the load balancing returns them to the user. In this way, when adding/removing a server, you only need to modify the load balancing server list without affecting server security. Avoid direct exposure of IP addresses and ports to the Internet, preventing hosts from being exploited for security vulnerabilities. The number of proxy servers is limited, making security protection more convenient.
5. References
Baidu, books
6. More discussions
1. What are the load balancing algorithms?
Answer: Round Robin method, random (Random) method, source address hash (Hash) method, weighted round robin (Weight Round Robin) method, weighted random (Weight Random) method, minimum Least Connections method.
2. What does the server name in the configuration mean?
Answer:
The server_name directive in Nginx is mainly used to configure name-based virtual hosts. The matching order of the server_name directive after receiving the request is:
1, Exact server_name matches
2, string starting with * wildcard character
3, string ending with * wildcard character
4, matching regular expression:
3. What is the difference between reverse proxy and load balancing?
Answer: Reverse proxy is a method to achieve load balancing. Let’s talk about reverse proxy first. When the user makes a request, he first sends the request to the proxy server, and then the proxy server requests the real server according to the algorithm, and finally returns it to the user. This approach, firstly, improves security; secondly, it shares user requests through multiple real servers and achieves load balancing. Let’s talk about load balancing again. The emergence of load balancing is to reduce the pressure on a single server as much as possible through horizontal expansion. Common WEB-level load balancing solutions include hardware F5, Nginx proxy, LVS, load balancing services of various cloud providers (such as AWS ELB service), etc. What is connected behind the load balancing is usually the server that actually provides the service. For example, through the ELB service, the traffic can be evenly shared, thereby reducing the pressure on the stand-alone server.
For more Nginx related technical articles, please visit the Nginx Tutorial column to learn!
The above is the detailed content of What does nginx reverse proxy mean?. For more information, please follow other related articles on the PHP Chinese website!