Nginx模块

作者: 你常不走的路 | 来源:发表于2018-03-15 11:56 被阅读7次

Nginx官方模块
第三方模块

模块一 stub_status

--with-http_stub_status_module Nginx的客户端状态,连接信息

配置语法
Syntax: stub_status;
Default: -
Context:server,location

修改 nginx.conf 中的 default.conf
应该在 /etc/nginx/site-enable/default.conf
vim default.conf
在server中 加上一个location

location /mystatus {
        stub_status;
}

这样就可以在访问时 输入指定域名 就可以查询到了一些连接信息

模块二 random_index

--with-http_random_index_module 目录中选择一个随机主页
随机主页 增加用户新鲜感 很少用
配置语法
Syntax: random_index on|off;
Default: random_index off;
Context:location

location / {
root /opt/app/code;; #放首页的目录
random_index on; #随机打开
}
nginx -tc 检查语法是否正确
ps -aux|grep nginx 查看进程状态

模块三 sub_module

--with-http_sub_module http内容替换

配置语法

Syntax: sub_filter string replacement;
Default: -
Context:http,server,location
string  代表 要替换的内容         #旧
replacement  要替换后的内容  #新
作用 头信息,服务端给客服端,校验头信息是否发生过变更,以时间的格式,判断是否有更新,有更新就发送更新的内容。
主要用于缓存
Syntax: sub_filter_last_modified on | off;
Default:sub_filter_last_modified off; #默认关闭
Context:http,server,location
作用 我是匹配html代码的第一个 ,还是所有字符串。
on 匹配第一个 ,off全匹配
Syntax: sub_filter_once on | off;
Default:sub_filter_once on; #默认开启
Context:http,server,location

使用sub_filter

location / {
        root /opt/app/code;;  #放首页的目录
        #random_index   on;   #随机打开 
        index   index.html    index.htm;
        sub_filter  '<a>someone'  '<a>SOMEONE'; 
        sub_filter_once   off;  
}
把html中的<a>someone 替换为<a>SOMEONE 只替换了第一个 因为sub_filter_once on默认是开启的 所以去把它关闭了

sub_filter_once off; 这样就可以替换所有了

相关文章

  • 6.Nginx模块学习方法

    Nginx模块 Nginx模块分为 Nginx官方模块 和 第三方模块 , 这里我们拿Nginx官方模块来介绍一下...

  • Nginx核心模块以及指令介绍

    Nginx模块概览 Nginx核心模块以及指令介绍 注意:Nginx的核心模块包含主模块和事件模块,即上图的cor...

  • 应用运维面试核心

    面试题 Nginx模块 你以前用过哪些Nginx模块? upstream 是Nginx负载均衡模块 image ...

  • nginx内核原理

    Nginx的模块 Nginx由内核和模块组成。 Nginx的模块从结构上分为核心模块、基础模块和第三方模块: 核心...

  • nginx 源代码分析 (二)

    1. nginx模块 nginx的功能分布在nginx模块中,一个模块为一个功能单元。每个nginx模块都专注于自...

  • nginx 动态添加模块

    需要用到nginx的tcp模块,以前安装的nginx没有这个模块。 ./nginx -V 可以看到所有包含的模块(...

  • 8.nginx模块介绍

    nginx的模块 1.编译进nginx的模块2.提供那些配置3.模块合适被使用4.提供那些变量 查找nginx模块...

  • nginx 2

    1 nginx 常用模块整理 nginx 常用模块整理1 http核心模块 ngx_http_core_modu...

  • centos7 使用nginx上传文件

    安装nginx以及nginx-upload-module模块 下载nginx源码,添加模块只支持源码编译:wget...

  • nginx与lvs详解

    详细描述常见nginx常用模块和模块的使用示例 nginx常见的模块分类: 核心模块:core moduleNgi...

网友评论

    本文标题:Nginx模块

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