Nginx config
Includes all nginx sites, snippets & required modules for homelab.
Modules
Current configuration files require the following modules:
We need to compile static modules like this from source (modules-available/) into *.so dynamic module files that can be loaded from modules/.1
headers-more-nginx-module
We want to add headers from snippets, and in server & location blocks, through snippets and define in location blocks. Nginx add_header directive by design only adds headers if not previously added, this means server & snippet headers will be removed from response if location block uses add_header.
There could be several add_header directives. These directives are inherited from the previous configuration level if and only if there are no add_header directives defined on the current level.2
Instead we use module headers-more to replace directive add_header 'key' 'value' with more_set_headers 'key value. This will prevent removing previously defined headers and enable setting headers from snippets, and in server & location blocks.
CI/CD
Drone CI config file defines compiling modules from source and transfering to nginx host during deploy step.
Setup environment: Current configs have references to SSL cert & key location. To validate nginx config with these references dummy cert & key files are created and symlinked to SSL cert & key locations defined in configs.
Compiling nginx binary & modules:
It is setup to pull git submodules and build modules-available/ from source. This requires us to pull latest nginx source-code, configure it, build and folder reference in --add-dynamic-module flag when compiling nginx.
Since we compile nginx binary from source we need to enable flags for all common nginx modules we use in configs. View flags in .circleci compile step. Flags currently set (prefix with --with-{NGINX_MODULE_NAME}):