Nginx (engine x) is a high-performance HTTP and reverse proxy web server, a lightweight web server/reverse proxy server and email (IMAP/POP3) proxy server; it is also Provides IMAP/POP3/SMTP services.
It releases source code under a BSD-like license and is known for its stability, rich feature set, sample configuration files, and low system resource consumption. . The characteristics of Nginx 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. Most websites in mainland my country use nginx.
So what can nginx be used for?
1. Static HTTP server
First of all, Nginx is an HTTP server that can store static files (such as HTML, pictures) on the server Displayed to the client through HTTP protocol.
2. Reverse proxy server
Reverse proxy should be the most common thing nginx does. What is a reverse proxy? The following is Baidu Encyclopedia Saying: The reverse proxy method refers to using a proxy server to accept connection requests on the Internet, then forwarding the requests to the server on the internal network, and returning the results obtained from the server to the client requesting the connection on the Internet. When the proxy server appears to the outside world as a reverse proxy server, simply put, the real server cannot be directly accessed by the external network, so a proxy server is needed, and the proxy server can be accessed by the external network and at the same time as the real server. A network environment may of course be the same server with different ports.
3. Load Balancing
When the website traffic is very large, the webmaster is happy to make money, but at the same time he is also in trouble. Because the website is getting slower and slower, one server is no longer enough. So the same application is deployed on multiple servers, and requests from a large number of users are distributed to multiple machines for processing. At the same time, the benefit is that if one of the servers crashes, as long as other servers are running normally, it will not affect the user's use.
Nginx can achieve load balancing through reverse proxy.
4. Virtual host
Some websites have a large number of visits and require load balancing. However, not all websites are so excellent. Some websites need to save costs by deploying multiple websites on the same server because the number of visits is too small.
For example, if two websites www.aaa.com and www.bbb.com are deployed on the same server, the two domain names resolve to the same IP address, but the user can open both through the two domain names. Completely different websites do not affect each other, just like accessing two servers, so they are called two virtual hosts.
5. Mail proxy server
Nginx is also a very excellent mail proxy server (one of the earliest purposes of developing this product is also as a mail proxy server), Last .fm describes a successful and wonderful experience.
The above is the detailed content of What can nginx be used for?. For more information, please follow other related articles on the PHP Chinese website!