Nginx--sub_filter模块

客户端浏览器访问替换html中的字符:

location / {
        root   /web/htdocs;
        random_index on;
        index  index.html index.htm;
        subs_filter_types   text/css text/plain application/x-javascript application/javascript;
        subs_filter         http:// 'https://';
        subs_filter         abc.org 'xyz.net';
        subs_filter         caoss.com 'css.net';//第一个参数是要被替换的,第二个参数是替换后的
        sub_filter_once     off;                //替换所有的,默认是on,替换第一个
      }

改完保存下,使用命令检查nginx语法是否正确:

[root@cms-nginx /]# /App/nginx/sbin/nginx -t
the configuration file /App/nginx//conf/nginx.conf syntax is ok
configuration file /App/nginx//conf/nginx.conf test is successful

平滑重启Nginx:

[root@cms-nginx /]# /App/nginx/sbin/nginx  -s reload

 

转载于:https://www.cnblogs.com/caoshousong/p/10763978.html

你可能感兴趣的:(Nginx--sub_filter模块)