Accept cookies for analytics, social media, and advertising, or learn more and adjust your preferences. These cookies are on by default for visitors outside the UK and EEA. Privacy Notice.
nginx_substitutions_filter - 応答ボディの正規表現および固定文字列の置き換えの両方が可能なフィルタモジュール。このモジュールはNGINXのネイティブの置換モジュールとはかなり異なります。出力チェインバッファーを走査し、Apacheのmod_substituteのように一行ごとに照合します。
注意
このモジュールはNGINXのソースと一緒に配布されません。 インストレーションの説明を見てください。
location / {
subs_filter_types text/html text/css text/xml;
subs_filter st(\d*).example.com $1.example.com ir;
subs_filter a.example.com s.example.com;
}
構文: | subs_filter_types mime-type [ mime-types ] |
---|---|
デフォルト: | text/html |
コンテキスト: | http, server, location |
subs_filter_typesはどのコンテントタイプがsubs_filterのために調査されるべきかを指定するために使われます。
このモジュールは平文テキストにだけ動作します。応答が圧縮されている場合、応答を解凍せずにこの応答を無視するでしょう。このモジュールはgzipフィルタモジュールと互換性があります。しかし、proxyの圧縮された応答とは動作しません。このようにして圧縮された応答を無効にすることができます:
proxy_set_header Accept-Encoding "";
構文: | subs_filter source_str destination_str [gior] |
---|---|
デフォルト: | g |
コンテキスト: | http, server, location |
subs_filter はNGINX応答内の元の文字列(正規表現あるいは固定)を目的の文字列で置き換えることができます。置換テキストは変数を含むかも知れません。locationごとに一つ以上の置換ルールがサポートされています。3つ目のフラグの意味は:
g
: 合致した全ての文字列を置換。i
: 大文字小文字を区別しない置換を実施。o
: 最初の1つだけを置換。r
: パターンを正規表現として扱います。デフォルトは固定文字列。インストールするには、subversionを使ってソースを取得します:
git clone git://github.com/yaoweibin/ngx_http_substitutions_filter_module.git
そして、NGINXを以下のオプションを使ってコンパイルします:
./configure --add-module=/path/to/module
06/30/2012: nginx_substitutions_filter 0.6.0 と切り替え
08/11/2010: nginx_substitutions_filter 0.5.2 と切り替え
04/15/2010: nginx_substitutions_filter 0.5 と切り替え
12/23/2009: nginx_substitutions_filter 0.4 と切り替え
02/04/2009: nginx_substitutions_filter 0.3 と切り替え
質問/パッチは Weibin Yao, yaoweibin@gmail.com に向けられるかもしれません。