nginx学习sub_filter模块

用户替换html中的字符

  location / {
        root   /opt/app/code/;
        random_index on;
        index  index.html index.htm;
        sub_filter '<h1>Admin' '<h1>ggggg';  //第一个参数是要被替换的,第二个参数是替换后的
        sub_filter_once off;   //替换所有的,默认是on,替换第一个
     }

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

nginx -tc /etc/nginx/nginx.conf

平滑重启nginx

nginx -s reload -c /etc/nginx/nginx.conf