yaoweibin / ngx_http_substitutions_filter_module

a filter module which can do both regular expression and fixed string substitutions for nginx
607 stars 213 forks source link

模块对javascript貌似无效 #15

Closed kkqy closed 9 years ago

kkqy commented 9 years ago

server { listen 80; server_name test.linzhihao.com; index index.php index.html index.htm;

    location / {
            default_type text/html;
            proxy_cache amproxy;
            subs_filter_types  text/css text/xml text/javascript application/javascript;
            subs_filter 'jQuery' '123' g;
            proxy_set_header X-Real-IP  $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Referer http://www.linzhihao.cn;
            proxy_set_header Host www.linzhihao.cn;
            proxy_pass http://www.linzhihao.cn;
            proxy_set_header Accept-Encoding "";
    }

}

这个是nginx的配置文件,当我访问 http://test.linzhihao.com/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.2.3 的时候,里面的jQuery并没有被替换为123

kkqy commented 9 years ago

应该不是浏览起缓存的问题,我换了浏览器,甚至用站长工具输出源码,结果显示都没有被替换

kkqy commented 9 years ago

上面的只是一个例子,因为有个js脚本里面会跳转到某个域名,我想把那个域名替换掉,结果发现不行,折腾了一会没找到原因。