Last Updated: July 16, 2021
·
5.758K
· rparet

nginx - add modules and repack on debian

Adding modules to nginx requires you to rebuild from source.

If you want to do this and keep the convenience of using dpkg's on debian, you can follow these steps:

Grab nginx build dependencies

apt-get build-dep nginx

Grab the source

cd /tmp && apt-get source nginx

Grab your module. In this case, we'll grab the nginx-fluentd module

cd /tmp && git clone git://github.com/fluent/nginx-fluentd-module.git

Add the custom module to debian rules file

Edit /tmp/nginx-*/debian/rules and the new --add-module directive along with the existing -add-module directives, i.e.
--add-module=/tmp/nginx-fluentd-module
under config.status.full

Note that you may have to add the module in multiple places, depending on what flavor of nginx you're building (full, light, naxsi, extras).

Create the package

cd /tmp/nginx-* && dpkg-buildpackage -uc -b

This will create many different debian packages. Grab the ones for the flavor you need and install!

To determine if your module got compiled/installed correctly use 'nginx -V' to see the compiled in modules. Your module should be in this list, like '/tmp/nginx-fluentd-module' in the above example.

Sources:
http://www.antazy.com/2010/11/ubuntu-nginx-recompilerepack-deb-with.html
http://serverfault.com/questions/227480/installing-optional-nginx-modules-with-apt-get