How to dynamically add modules to Nginx

How to dynamically add modules to Nginx

Written in front

Often, after we install Nginx based on the current project situation and business needs, as the business develops, we often add other functional modules to the installed Nginx. When adding function modules to Nginx, Nginx must not be shut down. This involves the question of how to dynamically add modules to the installed Nginx. In this article, we will discuss with you how to dynamically add modules to the installed Nginx.

Dynamically add modules to Nginx

Here we take the installation of the third-party ngx_http_google_filter_module module as an example.

Nginx modules require recompiling Nginx, rather than referencing .so in the configuration file like Apache.

Download the third-party extension module ngx_http_google_filter_module

# cd /data/software/
# git clone https://github.com/cuber/ngx_http_google_filter_module

Check which modules are installed when nginx is compiled and installed

Switch the command line to the directory where the Nginx execution program is located and enter ./nginx -V, as follows:

[root@binghe sbin]# ./nginx -V
nginx version: nginx/1.19.1
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.19.1 --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
[root@binghe sbin]#

It can be seen that the parameters used to compile and install Nginx are as follows:

--prefix=/usr/local/nginx-1.19.1 --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 the modules that need to be installed and recompile

Add here --add-module=/data/software/ngx_http_google_filter_module

The details are as follows:

./configure --prefix=/usr/local/nginx-1.19.1 --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

As above, add all the parameters of Nginx installed previously, and finally add --add-module=/data/software/ngx_http_google_filter_module

After that, we need to compile as follows:

# make //Don't make install, otherwise it will be overwritten

Here, it is important to note that: do not execute the make install command.

Replace nginx binary

# Back up the original nginx execution program# mv /usr/local/nginx-1.19.1/sbin/nginx /usr/local/nginx-1.19.1/sbin/nginx.bak
# Copy the newly compiled nginx executable program to the /usr/local/nginx-1.19.1/sbin/directory# cp /opt/nginx/sbin/nginx /usr/local/nginx-1.19.1/sbin/

Okay, let’s stop here for today! Don’t forget to like, follow and forward so that more people can see it, learn and improve together! !

The above is the detailed content of the method of dynamically adding modules to Nginx. For more information about dynamically adding modules to Nginx, please pay attention to other related articles on 123WORDPRESS.COM!

You may also be interested in:
  • How to recompile Nginx and add modules
  • Nginx dynamically forwards to upstream according to the path in the URL
  • Example of nginx ip blacklist dynamic ban
  • Nginx uses Lua+Redis to dynamically block IP
  • Detailed explanation of several ways to write Nginx dynamic DNS reverse proxy

<<:  How to elegantly implement WeChat authorized login in Vue3 project

>>:  Detailed introduction to Mysql date query

Recommend

HTML data submission post_PowerNode Java Academy

The HTTP request methods specified by the HTTP/1....

Implementation of CSS3 3D cool cube transformation animation

I love coding, it makes me happy! Hello everyone,...

JS implementation of Apple calculator

This article example shares the specific code of ...

Form submission page refresh does not jump

1. Design source code Copy code The code is as fol...

Example of how to implement keepalived+nginx high availability

1. Introduction to keepalived Keepalived was orig...

Vue based on Element button permission implementation solution

Background requirements: The ERP system needs to ...

How to manually scroll logs in Linux system

Log rotation is a very common function on Linux s...

Docker installs ClickHouse and initializes data testing

Clickhouse Introduction ClickHouse is a column-or...

MySQL FAQ series: When to use temporary tables

Introduction to temporary tables What is a tempor...

How to dynamically modify the replication filter in mysql

MySQL dynamically modify replication filters Let ...

Web Design Tutorial (2): On Imitation and Plagiarism

<br />In the previous article, I introduced ...

Analyzing the MySql CURRENT_TIMESTAMP function by example

When creating a time field DEFAULT CURRENT_TIMEST...

Detailed explanation of how to find the location of the nginx configuration file

How can you find the location of the configuratio...