Nginx Dynamic Modules

How Waddle loads nginx dynamic modules, like the Let's Encrypt (nginx-acme) module, through a rendered modules.conf that always matches your settings.

Every Waddle project has an nginx/conf/modules.conf file. It holds the load_module lines for the dynamic nginx modules your settings enable:

include "nginx/conf/modules.conf";

load_module is only allowed at the top level of nginx.conf, outside the http block, so this file can’t live in nginx/conf/conf.d/ or nginx/conf/extras/ like the rest of your project’s nginx config.

What it contains

Waddle renders modules.conf from your project settings, and it’s always present. When no dynamic module is enabled, it holds nothing but a comment.

Setting Module loaded
Let’s Encrypt enabled ngx_http_acme_module.so (nginx-acme), which requests and renews certificates

For example, with Let’s Encrypt turned on:

# Dynamic modules, included at the top of nginx.conf.
load_module /usr/local/nginx/modules/ngx_http_acme_module.so;

Why modules aren’t loaded from nginx.conf

nginx.conf is published from the nginx image into your project with rsync -ru, which only overwrites your copy when the image’s copy is newer. That happens whenever the nginx image is rebuilt, and then replaces your copy even if you’ve edited it (see Default Service Configs). Between rebuilds, your copy stays as it is.

A module is only compiled into the image while its configured, and nginx refuses to start if it’s told to load a module that isn’t there, or meets a directive from a module that isn’t loaded. So the load_module lines live in modules.conf instead, which Waddle re-renders whenever your settings change. It always matches the modules the image was actually built with.

Editing modules.conf

Don’t add your own lines to modules.conf. It’s a Waddle-rendered file: it gets rewritten when the related settings change, and Waddle flags your edits as changed on the next build.

Any module you load must also be compiled into the nginx image, or nginx won’t start.