How to enable dynamic module with an existing NGINX installation

If you are using docker nginx:latest this module is already included in the image as such you only need specify load_module as such:

"/usr/lib/nginx/modules/ngx_http_geoip_module.so";

You also need to create a geoip folder in your nginx mapped volume. Though the databases seem to no longer been updated or available and geoip2 modules are not included. So you many need to google...


Found this to be slightly different on Amazon Linux 2016.09, Amazon Linux 2016.03 after performing yum update.

You can confirm this ahead of time by using this command on your ec2 instance sudo yum search nginx-mod-http-geoip and you will see an N/S matched: nginx-mod-http-geoip entry in the response with specifics of nginx-mod-http-geoip.x86_64 : Nginx HTTP geoip module

In these cases, the installed nginx version will be 1.10.1. When this is true, you can simple install the nginx geoip module from Amazon's existing yum repo via:

sudo yum install nginx-mod-http-geoip

Then associate the module with your nginx.conf and placing this line in the main context

include /usr/share/nginx/modules/mod-http-geoip.conf;

(note this is subtly different from the main answer - in aws you have an entry in nginx.conf pointing to another *.conf file which then points to the *.so file)


I had the same issue, you have to install the http_geoip_module lib for your ubuntu version with:

$ sudo apt-get install nginx-module-geoip


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.