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/$1;}location ~/alias/(\w+\.txt){alias html/first/$1;}    

访问 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 200 '$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       80;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;

转载于:https://www.cnblogs.com/jackey2015/p/10375549.html

Nginx CONTENT阶段 static模块相关推荐

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

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

  2. nginx源码分析—模块及其初始化

    Content 0. 序 1. nginx有哪些模块? 2. nginx如何描述这些模块? 2.1 模块数据结构 2.1.1 ngx_module_t结构 2.1.2 ngx_command_t结构 ...

  3. Nginx系列五: handler 模块

    Nginx系列一:概念和配置 Nginx系列二: Nginx 的数据结构 Nginx系列三: Nginx 高级数据结构 Nginx系列四: Nginx的配置指令和handler模块概述 Nginx系列 ...

  4. 【nginx读取配置文件http模块】

    [nginx流程分析之读取配置文件http模块] http 配置文件 模块定义 结构体定义 ngx_http_module_t ngx_http_conf_ctx_t ngx_http_core_lo ...

  5. 【nginx 扩容及常用模块扩展】

    Nginx高级 第一部分:扩容 通过扩容提升整体吞吐量 1.单机垂直扩容:硬件资源增加 云服务资源增加 整机:IBM.浪潮.DELL.HP等 CPU/主板:更新到主流 网卡:10G/40G网卡 磁盘: ...

  6. 3、项目第四阶段——商品模块

    书城项目第五阶段-图书模块 1.MVC 概念 MVC 全称:Model 模型. View 视图. Controller 控制器. MVC 最早出现在 JavaEE 三层中的 Web 层,它可以有效的指 ...

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

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

  8. 安装好的nginx安装新的模块

    在工作中,经常会遇到nginx缺少某个模块,但又是线上环境,这样我们需如何解决? 1,查看安装的版本,如果有安装包就更好,没有去官网下载 nginx -v(小写的v) 2,查看nginx现有安装的模块 ...

  9. Linux的Nginx七:对比|模块

    对比 1.并发 Apache提供了几百个模块,模块就意味着功能,但作为一个Apache服务器最多只有2000多的并发量,Nginx提供的模块也就几十个,但他却可以提供20000的并放量. 2.异步 N ...

最新文章

  1. Markdown入门简介
  2. 计算机一级考试模拟题函数,2015年计算机一级考试模拟题(四)
  3. [转] 理解RESTful架构
  4. CentOS7.4到Elasticsearch一路坑(五)
  5. 位移时小心一下运算符的优先级
  6. windows如何安装python-windows下安装python过程
  7. java实现转账功能_如何利用Java代码模拟银行转账这一功能?
  8. 用SQL语言建表,课1
  9. 解决Vue跳转到当前路由报错问题
  10. 【交往智慧】005.做一个愿意聆听的人
  11. 操作系统 第一章 计算机系统概述
  12. facebook开源的prophet时间序列预测工具---识别多种周期性、趋势性(线性,logistic)、节假日效应,以及部分异常值
  13. 谈一谈python中的魔法变量*args和**kwargs
  14. 基于C#的房屋租赁管理系统设计与实现
  15. accept搭配用法_动词accept的用法与搭配
  16. Gateway 网关 (二) 全局过滤器
  17. 显示断开连接ntp服务器,ntp服务器连接异常咋办
  18. Python:正则表达式 re.sub()替换功能
  19. 计算机组成原理随堂作业,2019-华南理工-计算机组成原理-随堂作业
  20. java生成短信验证码_Java随机生成手机短信验证码的方法

热门文章

  1. input添加disabled属性出现的移动端兼容问题
  2. #每日播报# 8月6日 Github 热门项目汇总
  3. javascript-Global与Math对象
  4. 计算机网络 网络设备命令 数据链路层解析
  5. 解决了无法显示验证码的问题
  6. IE从服务器上获取json后转为下载提示的bug
  7. How run Powershell ISE on WIndows Server2008
  8. windows 7 PowerShell 笔记
  9. HTML中引入CSS的方法
  10. Mac快速显示桌面快捷键