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

Implementation of Docker to build Zookeeper&Kafka cluster

I've been learning Kafka recently. When I was...

Binary Type Operations in MySQL

This article mainly introduces the binary type op...

Introduction to Semantic XHTML Tags

The first point to make is that people can judge t...

JavaScript to implement login form

This article example shares the specific code of ...

Detailed tutorial on deploying SpringBoot + Vue project to Linux server

Preface Let me share with you how I deployed a Sp...

A brief discussion on using Vue to complete the mobile apk project

Table of contents Basic Configuration Entry file ...

MySQL merges multiple rows of data based on the group_concat() function

A very useful function group_concat(), the manual...

A brief discussion on JS packaging objects

Table of contents Overview definition Instance Me...

React new version life cycle hook function and usage detailed explanation

Compared with the old life cycle Three hooks are ...

Detailed explanation of system input and output management in Linux

Management of input and output in the system 1. U...

How to sort a row or column in mysql

method: By desc: Neither can be achieved: Method ...

Steps for importing tens of millions of data into MySQL using .Net Core

Table of contents Preliminary preparation Impleme...

Solution to mysql server 5.5 connection failure

The solution to the problem that mysql cannot be ...