SteveLTN / https-portal

A fully automated HTTPS server powered by Nginx, Let's Encrypt and Docker.
MIT License
4.42k stars 296 forks source link

Make Nginx configuration more modular #297

Closed MarcelWaldvogel closed 2 years ago

MarcelWaldvogel commented 2 years ago

Of course, It is possible to override the *.erb template files with your own template using volume: in docker-compose.yml. However, updates to the original templates inside the docker image will remain unnoticed, and will not be reflected, potentially causing problems as bug fixes (e.g. 0c35a4f4acfd99) or behavioral changes will not be reflected.

Making the configuration file more modular reduces the number of cases where the (brute-force) volume: file override method is required. It does not eliminate all problems that might occur through seemingly innocent changes in the docker template files, but many of them.

Anyone not using any of the new environment variables will not notice any difference, but the hooks are helpful if you have to fine-tune some behavior. For example, the CUSTOM_NGINX_GLOBAL_HTTP_CONFIG_BLOCK can be used to add a persistent proxy cache (proxy_cache_path only allowed at http level) or add additional server blocks which do not follow the normal rules (e.g., non-SSL server for a hostname, for which no SSL certificate can be obtained at all).

I use CUSTOM_NGINX_SERVER_PLAIN_CONFIG_BLOCK and ACME_CHALLENGE_BLOCK to handle failover scenarios which require modifying handling the ACME challenges.