nginx 配置示例
The location directive within NGINX server block allows to route request to correct location within the file system.
NGINX服务器块中的location指令允许将请求路由到文件系统中的正确位置。
The directive is used to tell NGINX where to look for a resource by including files and folders while matching a location block against an URL. In this tutorial, we will look at NGINX location directives in details.
该指令用于通过包含文件和文件夹,同时将位置块与URL匹配,来告诉NGINX在哪里寻找资源。 在本教程中,我们将详细介绍NGINX位置指令。
先决条件 (Prerequisite)
NGINX位置指令语法 (NGINX location directive syntax)
The NGINX location block can be placed inside a server block or inside another location block with some restrictions.
NGINX位置块可以在某些限制下放置在服务器块内或另一个位置块内。
The syntax for constructing a location block is:
构造位置块的语法为:
location [modifier] [URI] {
...
...
}
The modifier in the location block is optional. Having a modifier in the location block will allow NGINX to treat a URL differently. Few most common modifiers are:
位置块中的修饰符是可选的。 在位置块中使用修饰符将使NGINX可以不同地对待URL。 很少有最常见的修饰符是:
- none: If no modifiers are present in a location block then the requested URI will be matched against the beginning of the requested URI. none :如果位置块中没有修饰符,则所请求的URI将与所请求的URI的开头进行匹配。