L63-65

alias指令 

syntax: alias path;# 静态文件路径  alias不会将请求路径后的路径添加到 path中

context : location;

root指令

syntax : root path; #静态文件路径 root会将请求路径后添加的 path中

context : http,server,location,if in location

      location /root {
root html;
}
location /alias{
alias html;
} location ~/root/(\w+\.txt){
root html/first/$;
}
location ~/alias/(\w+\.txt){
alias html/first/$;
}

访问 http://xxxx/root 返回404 通过error日志 可以看到 会在html后加上root目录

访问 http://xxxx/alias 返回nginx主页面 返回正确

访问 http://xxxx/root/1.txt 返回404

访问 http://xxxx/alias/1.txt 则返回1.txt内容

 static模块三个变量

request_filename : 访问文件的完整路径包括扩展名

document_root : 由URI和root/alias规则生成的文件夹路径 

realpath_root : 将document_root软连接替换成真实路径

location /realpath{
alias html/realpath;
return '$request_filename:$document_root:$realpath_root\n';
}

访问 http://xxxx/realpath/1.txt 则返回 /usr/local/nginx/html/realpath/1.txt:/usr/local/nginx/html/realpath:/usr/local/nginx/html/realpath 输出的路径

当用户访问资源时没有在末尾加反斜杠的时候 NGINX会返回一个301的重定向

 指令 absolute_redirect  

syntax: on | off;

default : on;

context : http,server,location

 server {
listen ;
server_name localhost; absolute_redirect off; #关闭的时候
port_in_redirect on;
}

演示:当关闭absolute_redirect的时候 curl http://116.196.123.9/alias -i

当访问后  看到头部是不带域名的

Server: nginx/1.14.2
Date: Fri, 15 Feb 2019 08:26:21 GMT
Content-Type: text/html
Content-Length: 185
Connection: keep-alive
Location: /alias/  #我们看到没有完整域名

当打开的时候 就有 Location: http://192.xxx.xxx.1/alias/

指令 port_in_redirect 

syntax : on | off;

defaut : on;

context : http,server,location;

指令 server_name_in_redirect 主要控制 是否返回的 host域名 还是server_name主域名

syntax : on | off;

default : off;

context : http,server,location;

Nginx CONTENT阶段 static模块的更多相关文章

  1. Nginx CONTENT阶段 concat模块

    L67 concat_delimiter : 根据js 指定 分隔符 比如 “|” 那么每个文件分隔符为 “|” concat_types : 指定要合并文件的类型 concat_unique : s ...

  2. Nginx CONTENT阶段 autoindex、index模块

    L 66 autoindex 指令 syntax : on | off; default : off; context : http,server,location; autoindex_exact_ ...

  3. Nginx执行阶段

    Nginx 介绍 Nginx (engine x) 是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器. Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮 ...

  4. openresty开发系列35--openresty执行流程之5内容content阶段

    openresty开发系列35--openresty执行流程之5内容content阶段 content 阶段 ---init阶段---重写赋值---重写rewrite---access content ...

  5. Nginx的第一个模块-HelloWorld

    麻雀虽小,五脏俱全,小小的Hello World盛行于程序世界,就在于其代码虽短,但要真正运行起来,需要我们略通基本语法,稍懂编译运行环境,知晓操作过程,最后,还有一颗持之以恒,不怕折腾的心.前一阵子 ...

  6. Nginx 高级配置-第三方模块编译

    Nginx 高级配置-第三方模块编译 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 第三模块是对nginx 的功能扩展,第三方模块需要在编译安装Nginx 的时候使用参数--add ...

  7. Nginx一致性哈希模块的Lua实现

    Nginx一致性哈希模块的Lua重新实现 技术背景: 最近在工作中使用了nginx+redis 的架构,redis在后台做分布式存储,每个redis都存放不同的数据,这些数据都是某门户网站通过Hado ...

  8. nginx图片过滤处理模块http_image_filter_module安装配置笔记

    http_image_filter_module是nginx提供的集成图片处理模块,支持nginx-0.7.54以后的版本,在网站访问量不是很高磁盘有限不想生成多余的图片文件的前提下可,就可以用它实时 ...

  9. yum安装下的nginx,如何添加模块,和添加第三方模块

    需求:生产有个接口是通过socket通信.nginx1.9开始支持tcp层的转发,通过stream实现的,而socket也是基于tcp通信. 实现方法:Centos7.2下yum直接安装的nginx, ...

随机推荐

  1. Objective-C 事件响应链

    苹果app使用响应者对象(responder object)来接收和处理事件.响应者对象是NSResponder及其子类的实例,如NSView.NSViewController和NSApplicati ...

  2. Android 底部菜单会被顶起来的情况

    描述:主界面有一排底部菜单,当从主界面跳转到另一个界面,假如说这个界面有软键盘弹出,主界面的顶部菜单会被顶起来. 原因:系统软键盘造成的 解决办法:在返回主界面时将系统软键盘关掉即可

  3. ESP8266 wifi钓鱼

    原文链接: https://www.cnblogs.com/xiaowuyi/p/6980072.html https://www.cnblogs.com/xiaowuyi/p/7110652.htm ...

  4. IntelliJ IDEA常用设置(一)

    一.java文件中代码有错误,不点开java文件就不提示错误解决方法,版本不同可能界面有所区别. -->File->Settings->Build,Execution,Deploym ...

  5. IIS导入.pfx证书时报错:"A specified logon session does not exist. It may already have been terminated."

    在IIS中可以直接导入.pfx文件来给站点绑定https协议: 如果在导入.pfx文件时,不选择"Allow this certificate to be exported"的话 ...

  6. linux应用编程之进程间同步

    一.描述 在操作系统中,异步并发执行环境下的一组进程,因为相互制约关系,进而互相发送消息.互相合作.互相等待,使得各进程按一定的顺序和速度执行,称为进程间的同步.具有同步关系的一组并发进程,称为合作进 ...

  7. Angularjs实现select的下拉列表

    练习使用angularjs实现一个select下拉列表: <div ng-app="selectApp" ng-controller="selectControll ...

  8. (原创)odoo在docker环境下无法备份

    odoo容器内置postgresql-client版本和数据库版本不一致,安装和数据库版本相同或者更高版本的客户端 参考:https://www.postgresql.org/download/lin ...

  9. wpf 状态栏图标背景闪烁提醒 FlashWindowEx

    原文:wpf 状态栏图标背景闪烁提醒 FlashWindowEx using System; using System.Runtime.InteropServices; using System.Wi ...

  10. Luogu P1129 [ZJOI2007]矩阵游戏

    题目意思还是比较直观的,而且这个建模的套路也很明显. 我们首先考虑从主对角线可以转移到哪些状态. 由于每一次操作都不会把同一行(列)的黑色方块分开.因此我们发现: 只要找出\(n\)个黑色棋子,让它们 ...