摘要:某大神的博客說“在Nginx負載均衡服務器上,利用sub_filter指令在輸出的HTML中增加一行:
<style type="text/css">html {filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1); }</style>
就可以實現在IE及IE內核瀏覽器下,所有網站變灰色。” 特此試驗
主要步驟:
1、重新編譯nginx,增加http_sub_module模塊。
2、在nginx.conf配置文件的http {...}大括號內增加以下兩行:
sub_filter_once on;
正文
一、重新編譯nginx,添加新模塊
1.1 首先,查看之前編譯的一些參數
# /usr/local/nginx/sbin/nginx -V
1.2 進入nginx源碼包
# cd /usr/src/nginx-1.10.2
1.3 重新預配置,將要編譯的參數重新添加到后面(包括之前已經編譯過的模塊)

1.4編譯
#make
(*注:這里只能make 千萬別make install,否則就覆蓋安裝了)
1.5 make完成后,在源碼目錄下會有一個objs目錄,objs目錄下就多了個nginx,這個就是新版本的程序了。

將objs目錄下的nginx替換之前已經安裝過的nginx程序。
先備份舊的nginx程序,然后將新的nginx程序覆蓋過來

如果提示“cp:cannot create regular file `/usr/local/nginx/sbin/nginx': Text file busy”,建議使用如下語句cp #cp -rfp objs/nginx /usr/local/nginx/sbin/nginx
1.6 查看配置信息

1.7 測試新的nginx程序是否正確
# /usr/local/nginx/nginx -t
nginx: the configuration file /usr/local/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/nginx.conf test is successful
重啟服務
# /usr/local/nginx/nginx -s reload

二、修改配置文件
在nginx.conf配置文件的http {...}大括號內增加以下兩行:
sub_filter '</head>' '<style sub_filter '</head>' '<style type="text/css">html {filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1); }</style></head>';
sub_filter_once on; 
保存后,重新加載配置文件:
/usr/local/webserver/nginx/sbin/nginx –t
/usr/local/webserver/nginx/sbin/nginx -s reload
用ie瀏覽器測試

並沒有變灰 

