06 nginx Location详解之精准匹配
一:Location详解之精准匹配
location 语法
location 有”定位”的意思, 根据Uri来进行不同的定位.
在虚拟主机的配置中,是必不可少的,location可以把网站的不同部分,定位到不同的处理方式上.
比如, 碰到.php, 如何调用PHP解释器? --这时就需要location
location 的语法
location [=|~|~*|^~] patt {
}
中括号可以不写任何参数,此时称为一般匹配
也可以写参数
因此,大类型可以分为3种
location = patt {} [精准匹配]
location patt{} [一般匹配]
location ~ patt{} [正则匹配]
如何发挥作用?:
首先看有没有精准匹配,如果有,则停止匹配过程.
location = patt {
config A
}
如果 $uri == patt,匹配成功,使用configA
location = / {
root /var/www/html/;
index index.htm index.html;
}
location / {
root /usr/local/nginx/html;
index index.html index.htm;
}
如果访问 http://xxx.com/
定位流程是
1: 精准匹配中 ”/” ,得到index页为 index.htm
2: 再次访问 /index.htm , 此次内部转跳uri已经是”/index.htm” ,
根目录为/usr/local/nginx/html
3: 最终结果,访问了 /usr/local/nginx/html/index.htm
06 nginx Location详解之精准匹配的更多相关文章
- 06-Location详解之精准匹配
之前nginx不是编译过吗?现在重新make install一下. 刚刚这个是我们新安装的.原始版的nginx,配置文件比较少,便于我们做调试. 试试精准匹配的概念. 匹配的是/.优先匹配这个最精准的 ...
- nginx location详解
Location block 的基本语法形式是: location [=|~|~*|^~|@] pattern { ... } [=|~|~*|^~|@] 被称作 location modifier ...
- nginx location详解(三)
location官方文档:http://nginx.org/en/docs/http/ngx_http_core_module.html#location Syntax: location [ = | ...
- nginx入门与实战 安装 启动 配置nginx Nginx状态信息(status)配置 正向代理 反向代理 nginx语法之location详解
nginx入门与实战 网站服务 想必我们大多数人都是通过访问网站而开始接触互联网的吧.我们平时访问的网站服务 就是 Web 网络服务,一般是指允许用户通过浏览器访问到互联网中各种资源的服务. Web ...
- Nginx Rewrite详解
Nginx Rewrite详解 引用链接:http://blog.cafeneko.info/2010/10/nginx_rewrite_note/ 原文如下: 在新主机的迁移过程中,最大的困难就是W ...
- nginx配置详解(转)
Nginx 配置文件详解 user nginx ; #用户 worker_processes 8; #工作进程,根据硬件调整,大于等于cpu核数 error_log logs/nginx_error. ...
- nginx之旅(第一篇):nginx下载安装、nginx启动与关闭、nginx配置文件详解、nginx默认网站
一.nginx下载安装 版本nginx 1.15.5 系统环境centos7.5(本机ip192.168.199.228) 关闭selinux 和防火墙firewall 1.下载 wget http: ...
- Nginx配置详解 http://www.cnblogs.com/knowledgesea/p/5175711.html
Nginx配置详解 序言 Nginx是lgor Sysoev为俄罗斯访问量第二的rambler.ru站点设计开发的.从2004年发布至今,凭借开源的力量,已经接近成熟与完善. Nginx功能丰富,可作 ...
- Nginx系列(10)- Nginx配置文件详解
nginx文件结构 ... #全局块 events { #events块 ... } http #http块 { ... #http全局块 server #server块 { ... #server全 ...
随机推荐
- NAND Flash Bad Block Table
转:http://wiki.laptop.org/go/NAND_Flash_Bad_Block_Table 1 OLPC NAND Bad Block Management 1.1 Introduc ...
- andriod读写XML
AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xm ...
- [置顶]
使用kube-proxy让外部网络访问K8S service的ClusterIP
配置方式 kubernetes版本大于或者等于1.2时,外部网络(即非K8S集群内的网络)访问cluster IP的办法是: 修改master的/etc/kubernetes/proxy,把KUBE_ ...
- [置顶]
python3 django models保存filefiled字段统一目录、不修改文件名的方法
最经编写一个model时处理filefiled,使用post_form.save()进行新增和编辑文件保存位置不统一,如果出现重复文件名重复的话,上传文件名会被改名. 现有代码如下: models.p ...
- 【OpenGL4.0】GLSL渲染语言入门与VBO、VAO使用:绘制一个三角形 【转】
http://blog.csdn.net/xiajun07061225/article/details/7628146 以前都是用Cg的,现在改用GLSL,又要重新学,不过两种语言很多都是相通的. 下 ...
- Spark Streaming与Storm的对比及使用场景
Spark Streaming与Storm都可以做实时计算,那么在做技术选型的时候到底应该选择哪个呢?通过下图可以从计算模型.计算延迟.吞吐量.事物.容错性.动态并行度等方方面进行对比. 对比点 ...
- 【Hadoop】HADOOP 总结--思维导图
- scrapy爬虫 函数间传值简易教程
2017-03-27 有的时候我们爬取数据的时候需要在多个页面之间跳转,爬取完所有页面的数据的时候才能把所有数据一起存到数据库,这个时候我们就需要把某个函数内爬取的数据传到下一个函数当中.有人可能会说 ...
- [Tools] Create a Simple CLI Tool in Node.js with CAC
Command-line tools can help you with all sorts of tasks. This lesson covers the very basics of setti ...
- [React] Override webpack config for create-react-app without ejection
The default service worker that comes with create-react-app doesn't allow for very much configuratio ...