nginx 配置文件组成
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/e192a8ffb0d80b7ed0b80feff428efc8.png)
nginx 官网 location路径匹配
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/adfbdbfeae1860ba6ab069940002a7ed.png)
官网location 路径匹配规则介绍 http://nginx.org/en/docs/http/ngx_http_core_module.html#location
多个location 匹配顺序
多个location配置的情况下匹配顺序为,
- 首先匹配 = ,精确匹配,
- 其次匹配^~,
- 再次是按文件中顺序的正则匹配,即~ 或~*,
- 最后是普通字符匹配(匹配最长的),即uri 前无[ = | ~ | ~* | ^~ ] 。
当有匹配成功时候,停止匹配,按当前匹配规则处理请求。
匹配例子:
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/9d8d501c9f525c2d5afc60c2043244a4.png)