All Products
Search
Document Center

:How to dynamically add extension modules for Nginx

Last Updated:Dec 31, 2020

Overview

This article mainly describes how to dynamically add extension modules for Nginx.

Detail

Alibaba Cloud reminds you that:

  • Before you perform operations that may cause risks, such as modifying instance configurations or data, we recommend that you check the disaster recovery and fault tolerance capabilities of the instances to ensure data security.
  • You can modify the configurations and data of instances including but not limited to Elastic Compute Service (ECS) and Relational Database Service (RDS) instances. Before the modification, we recommend that you create snapshots or enable RDS log backup.
  • If you have authorized or submitted sensitive information such as the logon account and password in the Alibaba Cloud Management Console, we recommend that you modify such information in a timely manner.

To install the ngx_http_google_filter_module module, perform the following steps.

Note: Nginx modules need to be re-compiled, not like Apache configuration file reference .So.

  1. Run the following command to download the third-party extension module:
    cd /data/software/ 
    git clone https://github.com/cuber/ngx_http_google_filter_module
  2. Switch the command line to the directory where Nginx runs the program.
    cd /usr/local/nginx-1.9.3/sbin
  3. Enter the following command to view the module parameters installed on Nginx:
    ./nginx -V 
    The information returned by the system.
    nginx version: nginx/1.9.3 
    built by gcc 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC)
    built with OpenSSL 1.0.2 22 Jan 2015
    TLS SNI support enabled
    configure arguments: --prefix=/usr/local/nginx-1.9.3 --with-openssl=/usr/local/src/openssl-1.0.2 --with-pcre=/usr/local/src/pcre-8.37 --with-zlib=/usr/local/src/zlib-1.2.8 --with-http_ssl_module
    (: it can be seen that compilation to set up the installations or put them to use --prefix=/usr/local/nginx-1.9.3, --with-openssl=/usr/local/src/openssl-1.0.2, --with-pcre=/usr/local/src/pcre-8.37, --with-zlib=/usr/local/src/zlib-1.2.8, -with-http_ssl_module {{{ mtl abeletjj {parameters}.
  4. Run the following command to back up the original Nginx executable program.
    cp /usr/local/nginx-1.9.3/sbin/nginx /usr/local/nginx-1.9.3/sbin/nginx.bak 
  5. Use the following command to go to the directory where the Nginx installation package is located.
    cd /opt/nginx-1.9.3
    Note: the directory path depends on the installation directory of your instance.
  6. Join the need to install the module execute the following code .
    ./configure --prefix=/usr/local/nginx-1.9.3 --with-openssl=/usr/local/src/openssl-1.0.2 --with-pcre=/usr/local/src/pcre-8.37 --with-zlib=/usr/local/src/zlib-1.2.8 --with-http_ssl_module --add-module=/data/software/ngx_http_google_filter_module 
    Note: add -- add-module=/data/software/ngx_http_google_filter_module.
  7. Run the make command to compile the code.
    Note: do not run the makeinstall command to overwrite the existing installation content.

Application scope

  • Elastic Compute Service