Nginx multi-rule keyword replacement module subs_filter_module

Source: Internet
Author: User

This article introduces an nginx third-party module Nginx_substitutions_filter, which is the replacement of the filter response body, Nginx also has a similar to such a native module (http_sub_module ), but one drawback is that only one rule can be used, while Nginx_substitutions_filter has an unlimited number of rules (test efficiency is a little slower than the native module).


Installation method

1.SVN Checkout Http://substitutions4nginx.googlecode.com/svn/trunk/substitutions4nginx-read-only

2.yum Install Subversion


----------------------------------------------------------

For some other reason, you may not be able to connect to Googlecode then I have packed the tar package, unzip it and then recompile the installation Nginx: Http://pan.baidu.com/s/1pJBMk2Z 2014 NEW:

Http://pan.baidu.com/s/1c0rPPj6

The original Googlecode version seems to have stopped updating, and the author seems to have migrated to GitHub, https://github.com/yaoweibin/ngx_http_substitutions_filter_module/

Last update was 2014.02.15 added

Subs_filter_bypass

-------------------------------------------------------------


Compiling methods for adding additional third-party modules

CD Nginx/./configure--add-module=path/substitutions4nginx-read-only

The path here is the directory path of Substitutions4nginx-read-only

Make && make install


Usage:

There are two instructions: subs_filter_types,subs_filter

Subs_filter_types

Syntax: Subs_filter_types mime-type [Mime-types]

Default: Subs_filter_types text/html (High version of Nginx if there is a write bar, then restart the service will have a warning message, because the default is to check the text/html information, and the program has a duplicate configuration)

Applicable area: HTTP, server, location

Subs_filter_types is the type of file to be replaced by the directive, and the default is the text/html type. This module cannot process compressed content, although it can be compatible with the GZIP filter module, but cannot handle the content returned by the reverse proxy. When you need to process the contents of a reverse proxy, you can disable compression by using the following statement:

Proxy_set_header accept-encoding ';


Subs_filter

Subs_filter Source field string Target Field string [GioR]

Default: None

Applicable area: HTTP, server, location

The Subs_filter directive allows the replacement of the source field string (regular or fixed) as the target string when Nginx responds to output content. The third sign implies the following:

G (default): Replaces all matching field strings. (Can be omitted by default)

I: Performs a case-sensitive match.

O: Replace only the first matching string.

R: Use regular replacement mode, default is fixed mode.


Module website:

https://github.com/yaoweibin/ngx_http_substitutions_filter_module/


Substitutions has been tested to support Chinese substitution.

This article from "Professor elder brother" blog, reprint please contact the author!

Nginx multi-rule keyword replacement module subs_filter_module

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.