About Nginx
Nginx is a lightweight, high-performance, high-stability, and good concurrency HTTP and reverse proxy servers. Also because of its characteristics, its applications are very wide.
Main functions
Reverse proxy
Forward proxy: In some cases, proxy our users to access Server requires the user to manually set the IP and port number of the proxy server.
Reverse proxy: It is used to proxy the server and proxy the target server we want to access.
The proxy server accepts the request, then forwards the request to the server in the internal network (clustered),
and returns the result obtained from the server to the client. At this time, the proxy server is externally Appears as a server.
Nginx provides flexible functions on the reverse proxy. Different forwarding strategies can be adopted according to different regular rules. After setting up as shown in the figure, different requests can go through different paths. server.
Load balancing
Load balancing: It is mostly needed in high concurrency situations. The principle is to allocate data traffic to multiple servers for execution, reducing the pressure on each server. Multiple servers (clusters) work together to complete work tasks, thus improving data throughput.
The load balancing strategies that can be used by Nginx are: polling (default), weight, ip_hash, url_hash (third party), fair (third party)
Separation of dynamic and static
The dynamic and static separation provided by Nginx refers to the separation of dynamic requests and static requests. The appropriate server handles the corresponding requests, making the performance and efficiency of the entire server system higher.
Nginx can forward different requests differently according to the configuration, which is the basis of dynamic separation. The static resources corresponding to static requests can be directly placed on Nginx for buffering. A better approach is to place them on the corresponding buffer server. Dynamic requests are handled by the corresponding backend server.
For more Nginx related knowledge, please visit the Nginx usage tutorial column!
The above is the detailed content of What is the role of nginx. For more information, please follow other related articles on the PHP Chinese website!