Nginx basis: 3: Confirm method tripartite module

Here Insert Picture Description
nginx has a lot of community tripartite module offers many useful features, which are due to the default module does not include a way, is often needed to compile the source code to achieve the purpose of this article to subs_filter example, first tell us about confirmation method tripartite module.

subs_filter module

subs_filter means for replacing the URL, the process of performing forwarding has more common use. Set in the configuration file is generally like this:

subs_filter www.待替换的内容 [mirror_host_name];
subs_filter https:// http://;

That it contains the modules

Method 1: Use nginx -V

[root@liumiaocn nginx]# nginx -V
nginx version: nginx/1.16.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-stream_ssl_preread_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-http_auth_request_module --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E'
[root@liumiaocn nginx]# 

Confirm that it contains the appropriate module, the direct command may be used to confirm

[root@liumiaocn nginx]# nginx -V 2>&1 |grep subs_filter
[root@liumiaocn nginx]# 

The foregoing is an example of the log does not exist, using default nginx mounted at the CentOS yum, and the module will not be installed.

Method 2: acknowledgment / usr / lib64 / nginx / modules directory

/ Usr / lib64 / nginx / modules directory is obtained nginx -V installation directory module, the module will generally constituents present in the form of so files, to check whether the file corresponding to this directory so can be checked

[root@liumiaocn nginx]# ls /usr/lib64/nginx/modules
ngx_http_image_filter_module.so  ngx_http_perl_module.so  ngx_http_xslt_filter_module.so  ngx_mail_module.so  ngx_stream_module.so
[root@liumiaocn nginx]# 

Method 3: nginx profile is determined by

Add the location to replace the statement in paragraph nginx configuration files, such as the following statement speaks replaced http https

subs_filter https:// http://;

Then perform nginx -s reload to load, if you have this module, you can perform normal, otherwise it will prompt similar to the following log information

[root@liumiaocn nginx]# nginx -s reload
nginx: [emerg] unknown directive "subs_filter" in /etc/nginx/nginx.conf:53
[root@liumiaocn nginx]# 

Another example is the following example:

          subs_filter  http://www.google.com http://IP地址;
          subs_filter  https://www.google.com http://IP地址;

to sum up

This article describes how to confirm the tripartite module in nginx, the next will continue to introduce how to compile source code and settings.

Released 1028 original articles · won praise 1290 · Views 3.98 million +

Guess you like

Origin blog.csdn.net/liumiaocn/article/details/104104790