内容简介:./configure \--prefix=/application/nginx-1.6.3 \--user=nginx \
最近有个需求:需要过滤替换掉网站上部分内容,查了下资料NGINX自带过滤功能模块,于是实践了下,具体操作如下:
虽然是NGINX自带了with-http_sub_module模块,但是需要编译安装NGINX,并指定选项才可以正常使用。
需要编译安装NGINX(with-http_sub_module):
./configure \
--prefix=/application/nginx-1.6.3 \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_stub_status_module \
--without-http_gzip_module \
--with-http_sub_module
译安装NGINX:(ngx_http_substitutions_filter_module)
此模块需要先单独下载
下载地址:git clone git://github.com/yaoweibin/ngx_http_substitutions_filter_module.git
./configure \
--prefix=/application/nginx-1.6.3 \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_stub_status_module \
--without-http_gzip_module \
--with-http_sub_module \
--add-module=/application/ngx_http_substitutions_filter_module #指定模块路径
测试过程:建立测试站
配置文件如下:
[root@k8s conf]# cat nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
sub_filter nginx apache;
server {
listen 80;
server_name www.nginx.com;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
多站点测试:建立vhosts目录(多站点配置incule vhosts/*导入)
Bbs.conf :
server {
listen 80;
server_name bbs.nginx.com;
location / {
root /data/wwwroot/bbs;
index index.html index.htm;
}
}
Blogs.conf:
server {
listen 80;
server_name blogs.nginx.com;
location / {
root /data/wwwroot/blogs;
index index.html index.htm;
}
}
[root@k8s conf]# cat nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
subs_filter nginx apache;
subs_filter If apache;
subs_filter com cn;
;
;server {
listen 80;
server_name www.nginx.com;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
访问测试效果:
测试结果:1、sub_filter只支持单行,功能有限(加多行会报错)。
2、subs_filter支持多行过虑,且支持正则,功能较强大。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- JPress v3.0.2 发布,新增垃圾内容过滤功能
- 分析:基于文本内容推荐和协同过滤推荐
- 基于Spring Security Role过滤Jackson JSON输出内容
- 小程序-云开发:如何对敏感词进行过滤即内容安全的检测(上)
- iOS/macOS内容过滤器内核UAF漏洞分析和概念证明
- 从网易云日推浅谈个性化推荐系统--基于内容的协同过滤算法
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
计算机程序设计艺术:第4卷 第4册(双语版)
Donald E.Knuth / 苏运霖 / 机械工业出版社 / 2007-4 / 42.00元
关于算法分析的这多卷论著已经长期被公认为经典计算机科学的定义性描述。迄今已出版的完整的三卷组成了程序设计理论和实践的惟一的珍贵源泉,无数读者都赞扬Knuth的著作对个人的深远影响。科学家们为他的分析的美丽和优雅所惊叹,而从事实践的程序员们已经成功地应用他的“菜谱式”的解到日常问题上,所有人都由于Knuth在书中所表现出的博学、清晰、精确和高度幽默而对他无比敬仰。 为开始后续各卷的写作并更......一起来看看 《计算机程序设计艺术:第4卷 第4册(双语版)》 这本书的介绍吧!