Nginx模块分为:nginx官方模块、第三方模块

通过nginx -V查看编译参数,可以看到官方编译的模块

--with-compat
--with-file-aio
--with-threads
--with-http_addition_module
--with-http_auth_request_module
--with-http_dav_module
--with-http_flv_module
--with-http_gunzip_module
--with-http_gzip_static_module
--with-http_mp4_module
--with-http_random_index_module
--with-http_realip_module
--with-http_secure_link_module
--with-http_slice_module
--with-http_ssl_module --with-http_stub_status_module
作用:nginx的客户端连接状态
Syntax:stub_status;
Default:——
Context:server,location
--with-http_sub_module
--with-http_v2_module
--with-mail
--with-mail_ssl_module
--with-stream
--with-stream_realip_module
--with-stream_ssl_module
--with-stream_ssl_preread_module
--with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong
--param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC'
--with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'

--with-http_stub_status_module
作用:nginx的客户端连接状态

Syntax:stub_status

Default:——

Context:server,location

演示:

vi /etc/nginx/conf.d/default.conf

配置如图下:

location /mystatus {
        stub_status;
        }

使用配置是否正确

nginx -tc /etc/nginx/nginx.conf

然后重载服务

nginx -s reload -c /etc/nginx/nginx.conf

在浏览器中输入ip+路径

http://192.168.96.188/mystatus

Active connections: 1    #当前活跃的连接数
server accepts handled requests
1 1 1 # 第一个值代表握手总次数;第二个值代理处理的连接数;第三个值是总的请求数;(握手次数一般都等于连接数,代表连接没有丢失)
Reading: 0 Writing: 1 Waiting: 0 #读、写、等待

--with-http_random_index_module

作用:目录中选择一个随机主页

Syntax:random_index on | off

Default:random_index off

Context:location

演示:

在/opt/app/code目录下定义3个html文件1.html、2.html、3.html

分别复制如下代码

<html>
<head>
<meta charset="utf-8">
<title>imooc1</title>
</head>
<body style=""> # 红色
</body>
</html> <html>
<head>
<meta charset="utf-8">
<title>imooc1</title>
</head>
<body style=""> #黑色
</body>
</html> <html>
<head>
<meta charset="utf-8">
<title>imooc1</title>
</head>
<body style=""> #蓝色
</body>
</html>

修改配置文件

vi /etc/nginx/conf.d/default.conf

 location / {
root /opt/app/code;
random_index on;
#index index.html index.htm;
}

查看配置是否正确

nginx -tc /etc/nginx/nginx.conf

然后重载服务

nginx -s reload -c /etc/nginx/nginx.conf

在浏览器中访问ip,刷新页面就会变颜色了

--with-http_sub_module

作用:http内容替换

#1语法

Syntax:sub_filter string replacement

Default:——

Context:http,server,location

#2语法

Syntax:sub_filter_last_modified on|off

Default:sub_filter_last_modified off

Context:server,location

#3语法

Syntax:sub_filter_last_once on | off

Default:sub_filter_last_once on

Context:http,server,location

演示:

在/opt/app/code目录下添加html文件

复制如下代码,保存
<html>
<head>
<meta charset="utf-8">
<title>submodules</title>
</head>
<body>
<a>joy</a>
<a>at</a>
<a>imooc</a>
<a>joy</a>
<a>imooc</a>
</head>
</body>
</html>

访问 192.168.96.188/submodule.html。

通过配置语法替换“imooc“”的内容为“IMOOC_JOY”

vi /etc/nginx/conf.d/default.conf

加入下列代码

location / {
root /opt/app/code;
index index.html index.htm;
sub_filter '<a>imooc' '<a>IMOOC_JOY'; #sub_filter 后面添加需要替换内容,已经替换后的内容
}

访问 192.168.96.188/submodule.html

默认只替换一个

如果替换全部,加入新的语法

location / {
root /opt/app/code;
index index.html index.htm;
sub_filter '<a>imooc' '<a>IMOOC_JOY';
sub_filter_once off; #在原有基础加上此模块,off 关闭
}

保存访问地址,记得强刷或者清理缓存,此时内容全部替换

Nginx模块讲解的更多相关文章

  1. nginx 模块讲解

    1. 通用配置选项: --prefix=<path>          指定Nginx的安装路径,所有其他的路径都要依赖于该选项 --sbin-path=<path>     ...

  2. 【转】Nginx模块开发入门

    转自: http://kb.cnblogs.com/page/98352/ 结论:对Nginx模块开发入门做了一个helloworld的示例,简单易懂.也有一定的深度.值得一看. Nginx模块开发入 ...

  3. Nginx模块开发入门

    前言 Nginx是当前最流行的HTTP Server之一,根据W3Techs的统计,目前世界排名(根据Alexa)前100万的网站中,Nginx的占有率为6.8%.与Apache相比,Nginx在高并 ...

  4. [转] Nginx模块开发入门

    前言 Nginx是当前最流行的HTTP Server之一,根据W3Techs的统计,目前世界排名(根据Alexa)前100万的网站中,Nginx的占有率为6.8%.与Apache相比,Nginx在高并 ...

  5. Nginx模块开发入门(转)

    前言 Nginx是当前最流行的HTTP Server之一,根据W3Techs的统计,目前世界排名(根据Alexa)前100万的网站中,Nginx的占有率为6.8%.与Apache相比,Nginx在高并 ...

  6. Nginx模块开发入门(转)

    前言 Nginx是当前最流行的HTTP Server之一,根据W3Techs的统计,目前世界排名(根据Alexa)前100万的网站中,Nginx的占有率为6.8%.与Apache相比,Nginx在高并 ...

  7. Nginx模块

    模块概述 https://kb.cnblogs.com/page/98352/ Nginx模块工作原理概述 (Nginx本身支持多种模块,如HTTP模块.EVENT模块和MAIL模块,本文只讨论HTT ...

  8. FW: Nginx模块开发入门

    前言 Nginx是当前最流行的HTTP Server之一,根据W3Techs的统计,目前世界排名(根据Alexa)前100万的网站中,Nginx的占有率为6.8%.与Apache相比,Nginx在高并 ...

  9. Nginx 模块开发

    Nginx 模块概述 Nginx 模块有三种角色: 处理请求并产生输出的 Handler 模块 : 处理由  Handler  产生的输出的 Filter (滤波器)模块: 当出现多个后台 服务器时, ...

随机推荐

  1. CSS 个性化滚动条样式

    页面中有许多内容过多时,为了不影响整体布局,总会有滚动效果代替.but,许多情况浏览器自带的滚动条样式与整体UI 界面不搭啊,怎么办,当然作为界面的化妆师CSS就出手啦~ 滚动条样式由多个伪类组成 下 ...

  2. UVA 1343 - The Rotation Game-[IDA*迭代加深搜索]

    解题思路: 这是紫书上的一道题,一开始笔者按照书上的思路采用状态空间搜索,想了很多办法优化可是仍然超时,时间消耗大的原因是主要是: 1)状态转移代价很大,一次需要向八个方向寻找: 2)哈希表更新频繁: ...

  3. vue-learning:40 - Vuex - 第一篇:概念和基本使用

    vuex 第一篇 目录 vuex概念 state / mapState getter / mapGetter mutation / mapMutation action / mapAction mod ...

  4. jQuery 工具类函数-字符串操作函数

    调用名为$.trim的工具函数,能删除字符串中左右两边的空格符,但该函数不能删除字符串中间的空格,调用格式为: $.trim (str); 参数str表示需要删除左右两边空格符的字符串. <bo ...

  5. C# 大端小端转换

    关于大端和小端,是一个有趣的问题.本文告诉大家如何在C#转换大端和小端. 这里有一个有趣的故事,请看详解大端模式和小端模式 - CSDN博客 默认的 C# 使用的是小端,如果收到的消息是大端,那么就会 ...

  6. 【47.40%】【BZOJ 1875】[SDOI2009]HH去散步

    Time Limit: 20 Sec  Memory Limit: 64 MB Submit: 1363  Solved: 646 [Submit][Status][Discuss] Descript ...

  7. Educational Codeforces Round 63部分题解

    Educational Codeforces Round 63 A 题目大意就不写了. 挺简单的,若果字符本来就单调不降,那么就不需要修改 否则找到第一次下降的位置和前面的换就好了. #include ...

  8. 2019前端学习路线心得-黑马程序员pink老师

    在规划之前先给大家分享几点心得哈: 1. 学习,特别是在线学习,是非常辛苦的事情,为了少走弯路, 所以一定要系统学习,多借鉴与前辈们总结出来的经验. 2. 不要相信任何说 一周掌握 css, 一周学完 ...

  9. HBase的安装及使用

    一.摘要以前搜书吧的数据量比较小,使用数据库+静态文件存储的方式就可以搞定,主要有2个系统组成:网站前端+后台服务.事先把图书详情等一些固定内容生成html静态文件和前端的其他静态文件打包部署,动态变 ...

  10. 一点资讯 视频抓取 phantomjs

    # _*_ coding: utf- _*_ """ 思路: .列表页使用phantomjs模拟点击.每个链接只抓取第一页9-10条内容,按照标题去重 .布置定时任务,每 ...