From NGINX version 1.9.11 and upwarts, a new feature is introduced: dynamic modules.
With dynamic modules, you can optionally load separate shared object files at runtime as modules – both third-party modules and some native NGINX modules. (source)
I have NGINX installed from the mainline (currently 1.9.14) so it is capable to use dynamic modules. It has also the module I want dynamicly enabled:
nginx -V nginx version: nginx/1.9.14 built by gcc 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.1) built with OpenSSL 1.0.1f 6 Jan 2014 TLS SNI support enabled configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules ... --with-http_geoip_module=dynamic ...
Note the --with-http_geoip_module=dynamic
which loads the module I need (dynamically). Unfortunately, the documentation is lacking (some details) and I am unable to set this up.
I have an existing NGINX installation (not from source). But so far as I can understand I just need to build the module, place the generated module file in the right NGINX folder and enable it in the config file.
I tested this on a different machine (with the same configuration, but not a production machine), but I don't see the ngx_http_geoip_module.so
file. The commands I used:
wget http://nginx.org/download/nginx-1.9.14.tar.gz tar -xzf nginx-1.9.14.tar.gz cd nginx-1.9.14/ ./configure --with-http_geoip_module=dynamic
The NGINX Plus repository includes both dynamic modules authored by NGINX and approved modules authored by community contributors. You can access and install them using standard package management tools such as apt and yum .
Using the API for Dynamic Configuration The NGINX Plus REST API supports the following HTTP methods: GET – Display information about an upstream group or individual server in it. POST – Add a server to the upstream group. PATCH – Modify the parameters of a particular server.
Find which flags Nginx was compiled with under Unixlog --lock-path=/var/lock/nginx. lock --pid-path=/run/nginx. pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body .... ..
I had the same question, and @vladiastudillo answer was the missing piece I needed.
First add the nginx stable repo:
sudo add-apt-repository ppa:nginx/stable
Then run apt update:
sudo apt-get update
And get the nginx geoip module:
sudo apt-get install nginx-module-geoip
This will download and load the module to /usr/lib/nginx/modules
To load the nginx module,
open nginx.conf
:
sudo nano /etc/nginx/nginx.conf
add add below in the main context:
load_module "modules/ngx_http_geoip_module.so";
The module will be loaded, when you reload the configuration or restart nginx.
To dynamically “unload” a module, comment out or remove its load_module
directive and reload the nginx configuration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With