美文网首页
Nginx-location细节解析

Nginx-location细节解析

作者: lazyguy | 来源:发表于2018-01-11 15:55 被阅读0次

title: nginx中location细节解析
date: 2016-12-16 11:23:56
tags: nginx location
categories: nginx


location模块的路径匹配流程图:

image.png

可以简单记为起作用的顺序是
=(精准匹配) > (^~字符串前缀匹配,不考虑正则结果) > (正则location匹配*) > (字符串前缀匹配)

其中多个匹配的正则location起作用的顺序跟在conf文件中的顺序相关

location中的其他常见指令

root 寻址开始的根

可以在server context和location context下定义root,但是通常
为了避免冗余配置,在server上下文中配置一个root最好

error_page 错误页面

error_page 404 /404.html
可以单独配置在其中一个location模块中

location /a {
               root /Users/tobi/Pictures/; 
               error_page 404.html #放在上述目录下的/Users/tobi/Pictures/a/404.html
            } 

或者单独为error_page配置一个地址

     error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

autoindex(允许列出目录下的所有文件,默认关闭)

index(默认页面)

deny(禁止访问某个路径)

相关文章

  • Nginx-location细节解析

    title: nginx中location细节解析date: 2016-12-16 11:23:56tags: n...

  • iOS超级签名

    摘抄自:超级签名-原理/机制/技术细节-完全解析蒲公英:超级签名 超级签名-原理/机制/技术细节-完全解析 随着苹...

  • 从零学java笔录-第4篇 Hello word 细节说明

    本节主要内容: Hello word 细节说明 源码总结 命令解析 思考回答 1.Hello word 细节说明 ...

  • 心——细节解析

    〖心〗——细节解析 文/素国花令 [没人评自己来 系列] “我的眼睛坏掉了,可我的心没有。”​〖点题梗〗 ————...

  • 插件化学习

    atlas学习传送门github demo地址atlas插件化源码解析atlas插件化官方文档atlas原理细节解析

  • nginx-location及rewrite

    location正则写法 已=开头表示精确匹配如 A 中只匹配根目录结尾的请求,后面不能带任何字符串。 ^~ 开头...

  • Nginx-location配置详解

    语法规则:location [=|~|~*|^~] /uri/ { … } =开头表示精确匹配 ^~开头表...

  • nginx-location配置详解

    1)语法规则: location [=|~|~*|^~] /uri/ {...} 2)匹配顺序 匹配的原则为:匹配...

  • PER

    per深度解析 细节分析,很到位。 https://danieltakeshi.github.io/2019/07...

  • rust 解析命令行参数

    rust有专门的clap crate解析命令行参数,但是这里我尝试自己解析参数,可以更加方便控制细节。 效果如下

网友评论

      本文标题:Nginx-location细节解析

      本文链接:https://www.haomeiwen.com/subject/kgqtoxtx.html