Nginx HttpSubModule sub_filter模塊的過濾功能

<!--?xml version="1.0" encoding="UTF-8" standalone="no"?-->javascript

<p><br /><span style="font-family: Arial;">1.使用</span><a style="font-family: Arial;" href="http://wiki.nginx.org/HttpSubModule">HttpSubModule</a><span style="font-family: Arial;">模塊 </span></p> <div style="font-family: Arial;"><br /> <div>--with-http_sub_module option</div> </div> <div style="font-family: Arial;">2.Nginx JavaScript 埋點 :</div> <div style="font-family: Arial;"><span style="background-color: #f0f0f0; color: #555555; font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', Arial, Verdana, sans-serif; font-size: 14px; line-height: 17.265625px; text-align: left;"><br /></span></div> <pre style="margin: 0px 4em 2em 2em; unicode-bidi: embed; border: 3px solid #ffffff; padding: 0.5em; background-color: #f9f9f9; color: #555555; font-size: 12px; width: 986.671875px; line-height: 17.265625px; text-align: left;">location / { sub_filter &lt;/head&gt; '&lt;/head&gt;&lt;script language="javascript" src="$script"&gt;&lt;/script&gt;'; sub_filter_once on; sub_filter_types text/html; } </pre> <div style="font-family: Arial; text-align: left;"><span style="color: #555555; font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', Arial, Verdana, sans-serif;"><span style="font-size: 14px; line-height: 17px;">3.</span></span>實如今IE及IE內核瀏覽器下,全部網站變灰色</div> <pre style="margin: 0px 4em 2em 2em; unicode-bidi: embed; border: 3px solid #ffffff; padding: 0.5em; background-color: #f9f9f9; color: #555555; font-size: 12px; width: 986.671875px; line-height: 17.265625px; text-align: left;">sub_filter ‘&lt;head&gt;’ ‘&lt;style type="text/css"&gt;html {filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1); }&lt;/style&gt;&lt;/head&gt;’; </pre> <p style="margin: 0px; padding: 0px 0px 8px; text-indent: 28px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; letter-spacing: 1px; line-height: 28px;">解釋:</p> <p style="margin: 0px; padding: 0px 0px 8px; text-indent: 28px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; letter-spacing: 1px; line-height: 28px;">sub_filter 一行代碼前面是須要替換的內容,後面單引號內是替換成的內容。</p> <p style="margin: 0px; padding: 0px 0px 8px; text-indent: 28px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; letter-spacing: 1px; line-height: 28px;">sub_filter_once 意思是隻查找並替換一次。on是開啓此功能,off是關閉——默認值是on。</p> <p style="margin: 0px; padding: 0px 0px 8px; text-indent: 28px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; letter-spacing: 1px; line-height: 28px;">sub_filter_types 一行意思是選定查找替換文件類型爲文本型。也能夠不加此行,由於默認只查找text/html文件。</p> <p style="margin: 0px; padding: 0px 0px 8px; text-indent: 28px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; letter-spacing: 1px; line-height: 28px;">sub_filter模塊能夠用在http, server, location模塊中。主要做用就是查找替換文件字符。</p> <div style="font-family: Arial; text-indent: 28px;"><span style="color: #333333; font-family: Arial, Helvetica, sans-serif;"><span style="font-size: 14px; letter-spacing: 1px; line-height: 28px;">比較實用的例子,增長</span></span>google analytics等網站分析嵌碼,或全局的樣式等</div> <p><span style="font-family: Arial;">PS:sub_filter Only one substitution rule per location is supported 不然會報以下錯誤</span></p> <div style="font-family: Arial; text-align: left;">nginx: [emerg] "sub_filter" directive is duplicate in /Dev/tengine/nginx/conf/nginx.conf:52Nginx HttpSubModule sub_filter模塊的過濾功能</div>css

相關文章
相關標籤/搜索