nginx中多規則替換過濾模組nginx_substitutions_filter用法

來源:互聯網
上載者:User

安裝方法:
 

 代碼如下 複製代碼
cd /tmp
yum install subversion
svn checkout http://substitutions4nginx.googlecode.com/svn/trunk/ substitutions4nginx-read-only

在編譯nginx時加上:
 

 代碼如下 複製代碼
./configure --add-module=/tmp/substitutions4nginx-read-only

使用方法
有兩條指令:subs_filter_types,subs_filter
subs_filter_types
文法: subs_filter_types mime-type [mime-types]
預設:subs_filter_types text/html
適用地區:http, server, location
subs_filter_types是用來指令需要替換的檔案類型,預設是text/html類型。此模組無法處理經過壓縮的內容,雖然能與gzip filter模組相容,但無法處理反向 Proxy返回的內容。
當需要處理反向 Proxy的內容時,可以使用如下語句禁用壓縮:
proxy_set_header Accept-Encoding "";
subs_filter
文法;subs_filter 源欄位串 目標欄位串 [gior]
預設:無
適用地區:http, server, location

    subs_filter指令允許在nginx響應輸出內容時替換源欄位串(正則或固定)為目標字串。第三個標誌含意如下:
    g(預設): 替換所有匹配的欄位串。
    i: 執行區分大小寫匹配。
    o: 僅替換首個匹配字串。
    r: 使用正則替換模式,預設是固定模式。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.