![]() -m signifies that we want to make changes to the ACL.-d sets the default permission for the /home directory.For instance, if is hosted on port 80 of 192.168.1.10, a request for will always be served by the first block in this example, despite the server_name directive in the second block. ![]() It is important to understand that Nginx will only evaluate the server_name directive when it needs to distinguish between server blocks that match to the same level of specificity in the listen directive. If there are multiple server blocks with the same level of specificity matching, Nginx then begins to evaluate the server_name directive of each server block. If there is only one most specific match, that server block will be used to serve the request.In any case, the port must be matched exactly. This means that any block that is functionally using 0.0.0.0 as its IP address (to match any interface), will not be selected if there are matching blocks that list a specific IP address. Nginx then attempts to collect a list of the server blocks that match the request most specifically based on the IP address and port.A block set to port 8888 with no IP address becomes 0.0.0.0:8888.A block with no listen directive uses the value 0.0.0.0:80.Nginx translates all “incomplete” listen directives by substituting missing values with their default values so that each block can be evaluated by its IP address and port.When trying to determine which server block to send a request to, Nginx will first try to decide based on the specificity of the listen directive using the following rules: The last option will generally only have implications when passing requests between different servers. A lone port which will listen to every interface on that port.A lone IP address which will then listen on the default port 80.This allows these blocks to respond to requests on any interface on port 80, but this default value does not hold much weight within the server selection process. By default, any server block that does not include a listen directive is given the listen parameters of 0.0.0.0:80 (or 0.0.0.0:8080 if Nginx is being run by a normal, non- root user). The listen directive typically defines which IP address and port that the server block will respond to. It matches this against the listen directive of each server to build a list of the server blocks that can possibly resolve the request. Parsing the listen Directive to Find Possible Matchesįirst, Nginx looks at the IP address and the port of the request. The main server block directives that Nginx is concerned with during this process are the listen directive, and the server_name directive. It does this through a defined system of checks that are used to find the best possible match. Since Nginx allows the administrator to define multiple server blocks that function as separate virtual web server instances, it needs a procedure for determining which of these server blocks will be used to satisfy a request. How Nginx Decides Which Server Block Will Handle a Request The URI space can be subdivided in whatever way the administrator likes using these blocks. Administrators often configure multiple server blocks and decide which block should handle which connection based on the requested domain name, port, and IP address.Ī location block lives within a server block and is used to define how Nginx should handle requests for different resources and URIs for the parent server. The main blocks that we will be discussing are the server block and the location block.Ī server block is a subset of Nginx’s configuration that defines a virtual server used to handle requests of a defined type. This decision process is what we will be discussing in this guide. Each time a client request is made, Nginx begins a process of determining which configuration blocks should be used to handle the request. Nginx logically divides the configurations meant to serve different content into blocks, which live in a hierarchical structure. Understanding these ideas can help take the guesswork out of designing server and location blocks and can make the request handling seem less unpredictable. In this guide, we will discuss some of the behind-the-scenes details that determine how Nginx processes client requests. It can successfully handle high loads with many concurrent client connections, and can function as a web server, a mail server, or a reverse proxy server. Nginx is one of the most popular web servers in the world.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |