标题:利用Nginx sub模块对网页内容进行替换 出处:沧海一粟 时间:Thu, 20 May 2021 08:22:01 +0000 作者:jed 地址:http://www.dzhope.com/post/1195/ 内容: 在我们环境下,经常需要运营对网站进行测试,但是偶尔会出现不知道是在测试环境还是正式环境,因为测试环境都是通过Nginx反向代理进行访问.因此本文利用Nginx进行网页内容替换,然后在醒目位置进行提醒,以达到对测试环境的标识作用 yum -y install openssl openssl-devel 在编译nginx的时候添加--with-http_sub_module以加载sub模块 nginx官网下载安装包:http://nginx.org/en/download.html wget http://nginx.org/download/nginx-1.11.5.tar.gz tar -zxvf nginx-1.11.5.tar.gz cd nginx-1.11.5 ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --without-http_rewrite_module make make install 如果全是测试环境的反向代理就只需要在http里头添加,当然也可以针对单个站点 sub_filter 测试服务器