见官方文档:http://nginx.org/en/docs/http/ngx_http_sub_module.html
The ngx_http_sub_module
module is a filter that modifies a response by replacing one specified string by another.
This module is not built by default, it should be enabled with the --with-http_sub_module
configuration parameter.
Example Configuration
location / { sub_filter '<a href="http://127.0.0.1:8080/' '<a href="https://$host/'; sub_filter '<img src="http://127.0.0.1:8080/' '<img src="https://$host/'; sub_filter_once on; }
Directives
sub_filter |
— |
http , server , location
|
Sets a string to replace and a replacement string. The string to replace is matched ignoring the case. The string to replace (1.9.4) and replacement string can contain variables. Severalsub_filter
directives can be specified on one configuration level (1.9.4). These directives are inherited from the previous level if and only if there are no sub_filter
directives defined on the current level.
sub_filter_last_modified |
sub_filter_last_modified off; |
http , server , location
|
This directive appeared in version 1.5.1.
Allows preserving the “Last-Modified” header field from the original response during replacement to facilitate response caching.
By default, the header field is removed as contents of the response are modified during processing.
sub_filter_once |
sub_filter_once on; |
http , server , location
|
Indicates whether to look for each string to replace once or repeatedly.
sub_filter_types |
sub_filter_types text/html; |
http , server , location
|
Enables string replacement in responses with the specified MIME types in addition to “text/html
”. The special value “*
” matches any MIME type (0.8.29).
相关推荐
主要介绍了Nginx记录分析响应慢的请求及替换网站响应内容的配置,分别用到了ngx_http_log_request_speed模块和ngx_http_sub_module模块,需要的朋友可以参考下
第35章 Nginx对响应体内容的替换 第36章 Nginx的WebDAV 第37章 Nginx的Xslt模块 第38章 Nginx的基本认证方式 第39章 Nginx的cookie 第40章 Nginx基于客户端请求头的访问分类 第41章 通过Upstream模块使得Nginx...
第35章 Nginx对响应体内容的替换 第36章 Nginx的WebDAV 第37章 Nginx的Xslt模块 第38章 Nginx的基本认证方式 第39章 Nginx的cookie 第40章 Nginx基于客户端请求头的访问分类 第41章 通过Upstream模块使得Nginx...
第35章 Nginx对响应体内容的替换 第36章 Nginx的WebDAV 第37章 Nginx的Xslt模块 第38章 Nginx的基本认证方式 第39章 Nginx的cookie 第40章 Nginx基于客户端请求头的访问分类 第41章 通过Upstream模块使得Nginx...
nginx普通用户安装手册,内含安装nginx 的其他相关软件,默认本机要有gcc工具,否则需要root 权限安装。内含nginx配置文件,已实现动态替换响应内容,百度搜索反向代理,负载均衡配置。
它用于nginx在响应请求文件底部追加内容. 今天抽空研究下这个插件,希望对大家有所帮助。为什么发现了这个插件,因为这几天公司需要在所有shtml文件后面追加一个js代码用来做统计(之前统计 代码没加齐全),在寻求...
有时候我们想对响应(例如PHP接口)返回的内容做些字符串,虽然可以使用各语言代码相关方法(例如PHP的str_replace)进行替换,但是在nginx层面替换是更方便的,无需修改代码。 约定:本文源代码目录统一放在:/...
nginx 1.17.7(mainline version)发布了,此版本主要是修复 bug,变更内容如下: Bugfix:如果在配置中使用了带有空替换字符串的"rewrite"指令,则可能在启动或重新配置期间发生分段错误 Bugfix:如果将"break...
名称ngx_replace_filter-响应主体中的流式正则表达式替换。 该模块不随Nginx源一起分发。 请参阅。目录社区英文邮件列表中文邮件列表错误和补丁作者版权和许可也可以看看 地位尽管仍处于开发的早期阶段,该模块已经...
它用于nginx在响应请求文件底部追加内容. 今天抽空研究下这个插件,希望对大家有所帮助。为什么发现了这个插件,因为这几天公司需要在所有shtml文件后面追加一个js代码用来做统计(之前统计代码没加齐全),在寻求...
如果是iis独立主机用户请在安装好Rewrite模块后,将默认的http.ini中的内容替换掉,如果是虚拟主机用户请将目录中的.htacess文件放到您所安装的根目录中。 iii.如果是nginx独立主机用户请将nginx.conf中的内容复制...
Consistency(一致性), 数据一致更新,所有数据变动都是同步的 Availability(可用性), 好的响应性能 Partition tolerance(分区容忍性) 可靠性 28 客户端负载均衡器 29 客户端负载均衡器 29 Ribbon与Nginx区别 29 ...
环境: 前端 vue ip地址:192.168.1.205 ...搜索问题,发现跨域,服务器响应的setCookie浏览器无法保存,而且就算保存了域名不同也不能携带。 第一步: 后台添加过滤器,因为前后端分离,不可能每个方
padding-bottom:110px}(首页设置)增加书籍分类添加seo标题连接符设置(seo设置)调整下载弹窗样式全屏加载效果(颜色效果)添加统计代码填写框(页脚设置)管理员可见替换为默认的私密模式增加首页排序规则设置...
高效是因为她完全用C编写而成,采用多进程+多路复用模型,参考Nginx。 低耗是因为空载运行只占了几MB内存,特别适合买不起高配云服务器的个人开发者。对于企业来说,现在动不动就要求8、16、32GB内存配置,如果软件...
高效是因为她完全用C编写而成,采用多进程+多路复用模型,参考Nginx。低耗是因为空载运行只占了几MB内存,特别适合买不起高配云服务器的个人开发者。对于企业来说,现在动不动就要求8、16、32GB内存配置,如果软件能...
- 全平台兼容性:Win Linux Mac (Apache、Nginx、IIS) #### 2.使用场景: - 取代FTP,服务端、客户端软件等复杂的安装配置。kod可以一键安装随处使用. - 你可以用它来管理你的服务器(备份,在线解压缩,版本发布......
超快的速度:全面采用Ajax+Json进行数据通信,毫秒级的响应速度; 全平台兼容性:Win Linux Mac (Apache、Nginx、IIS) 使用场景: 取代古老的FTP,服务端、客户端软件等复杂的安装配置。kod可以一键安装随处使用. 你...
超快的速度:全面采用Ajax+Json进行数据通信,毫秒级的响应速度; 全平台兼容性:Win Linux Mac (Apache、Nginx、IIS) 使用场景: 取代古老的FTP,服务端、客户端软件等复杂的安装配置。kod可以一键安装随处使用. 你...