nginx默认未编译此模块;让nginx编译启用此模块

./configure --prefix=/data/web --sbin-path=/usr/bin --user=nginx --group=nginx --with-http_stub_status_module --with-http_auth_request_module --with-http_sub_module --add-module=/root/nginx-http-concat --with-http_addition_modulemake
mv /usr/bin/nginx{,.07.12.13.18}cp objs/nginx /usr/bin/

addition指令介绍
Syntax: add_before_body uri; #在body之前添加,添加的内容就是后面的uri,让nginx去访问这个uri获取资源,根户请求返回的添加待body之前
Default: —
Context: http, server, location
Syntax: add_after_body uri;  # 在body之后添加
Default: —
Context: http, server, location
Syntax: addition_types mime-type ...;  #那些资源类型的请求可以使用
Default: addition_types text/html;
Context: http, server, location

  配置不启用时;配置

[root@python vhast]# cat addition.conf
server {server_name addition.com;access_log logs/addition.log main;location / {#add_before_body /before_action;#add_after_body /after_action;#addition_types *;}location /before_action {return 200 'new centos before_action\n';}location /after_action {return 200 'new centos after_action\n';}
}

  测试

[root@python vhast]# curl addition.com
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>body {width: 35em;margin: 0 auto;font-family: Tahoma, Verdana, Arial, sans-serif;}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>

  启用配置

[root@python vhast]# cat addition.conf
server {server_name addition.com;access_log logs/addition.log main;location / {add_before_body /before_action;  头部添加;这个uri返回的结果add_after_body /after_action;  尾部添加;这个uri返回的结果addition_types *;}location /before_action {return 200 'new centos before_action\n';}location /after_action {return 200 'new centos after_action\n';}
}

  测试

[root@python vhast]# curl addition.com
new centos before_action
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>body {width: 35em;margin: 0 auto;font-family: Tahoma, Verdana, Arial, sans-serif;}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>
new centos after_action

转载于:https://www.cnblogs.com/rdchenxi/p/11176953.html

nginx的addition模块在响应的前后报文添加内容与变量的运行原理相关推荐

  1. nginx安全下载模块ngx_http_secure_link_module

    nginx安全下载模块可以给服务器文件链接添加时间戳和校验码,从而保护服务器文件不被任意下载盗用.nginx的ngx_http_secure_link_module模块和lighttpd的sec_do ...

  2. Nginx Http 过滤模块

    L69 执行顺序在content阶段后 log阶段前调用的 也就是处理完用户业务后 准备记录处理日志之前 我们可以到nginx http_model.c里查看 数组 执行顺序从下至上顺序执行 copy ...

  3. 1. nginx扩展——ngx_lua 模块简介、安装

    1. 简介 ​ lua-nginx-module(ngx_lua module)把 Lua5.1 的解释器 或 LuaJIT 2.0/2.1 的解释器嵌入到 nginx 中,将强大的 Lua 线程(L ...

  4. Nginx源码研究之nginx限流模块详解

    这篇文章主要介绍了Nginx源码研究之nginx限流模块详解,小编觉得挺不错的,现在分享给大家,也给大家做个参考.一起跟随小编过来看看吧 高并发系统有三把利器:缓存.降级和限流: 限流的目的是通过对并 ...

  5. FastDFS的配置、部署与API使用解读(7)Nginx的FastDFS模块(转)

    1.Nginx的FastDFS模块什么作用? 我们在使用FastDFS部署一个分布式文件系统的时候,通过FastDFS的客户端API来进行文件的上传.下载.删除等操作.同时通过 FastDFS的HTT ...

  6. 搞懂nginx的proxy模块-01

    搞懂nginx的proxy模块-01 nginx的ngx_http_proxy_module模块的指令着实是太多了,其实平时工作中经常用到的指令也就是那几个,但是如果不细看下文档的话,下次对一些配置的 ...

  7. Nginx 基于nginx-sticky-module模块进行会话保持

    sticky介绍 sticky模块与Ip_hash都是与负载均衡算法相关,但又有差别,差别是 1.ip hash,根据客户端的IP,将请求分配到不同的服务器上 2.sticky,根据服务器给客户端的c ...

  8. Nginx的 http_image_filter_module 模块使用说明

    Nginx图片处理原理 这里需要用到 nginx的 http_image_filter_module 模块,这个模块可以很方便的实现图片缩放功能,只是默认的情况下并不会安装,需要自己编译安装才能行.编 ...

  9. 五种IO模型和nginx的web模块

    IO模型和nginx模块 IO模型 前言 消息通知 IO模型 nginx nginx模块 安装nginx nginx.conf的配置 main段相关指令 HTTP模块配置 与套接字相关的配置 与路径相 ...

最新文章

  1. qt tablewidget 实现tab来回切换_原生JS实现TAB选项卡切换效果
  2. 怎么自学python语言-python应用:零基础Python应该怎样学习呢?
  3. 树莓派_FTP服务器的搭建
  4. Android基站定位
  5. 《机器学习导论》和《统计机器学习》学习资料:张志华教授
  6. 简单的Gradle Java插件自定义
  7. easyui修改css样式,修改easyui的easyloader的默认css目录路径
  8. vscode使用相关配置
  9. dfs深度优先搜索_图的深度优先搜索(DFS)
  10. 程序员面试金典——18.12最大和子矩阵
  11. pcie转sata3硬盘不启动_新品推荐:PCIe2.0转4口SATA3/6G扩展卡 SFF8087
  12. Redis从安装到简单使用(windows)
  13. 2018程序员必读书单
  14. 关于springboot无法跳转解析html,404,500无法创建实体类工厂
  15. 姿态估计mmpose一手体验 Ⅱ - 使用它!
  16. Python面向对象06/反射/双下方法
  17. 简述数据、数据元素、数据项、数据对象、数据结构、逻辑结构、存储结构、抽象数据类型
  18. 升级IE7.0的唯一理由
  19. LDA模型,获取所有的文档-主题分布(即得到文档对于每个主题的概率分布)并保存
  20. 2019年3月计算机一级考试试题,2019年3月计算机一级考试MsOffice操作试题(五)

热门文章

  1. android gridview滚动监听,检测GridView滚动速度 – Android
  2. java播放mp3背景音乐_Java如何实现MP3播放!!
  3. windows cmd 定义和使用变量
  4. MYSQL5.6 设置root用户密码
  5. Kotlin入门(3)基本变量类型的用法
  6. Android开发笔记(五十六)摄像头拍照
  7. WordPress 安装插件导致 HTTP 500 内部服务器错误的问题
  8. Java进阶篇设计模式之十三 ---- 观察者模式和空对象模式
  9. 组策略之文件夹的重定向
  10. 《计算机系统:系统架构与操作系统的高度集成》——3.2 处理器实现涉及什么...