Nginx Configuration Generator
nginx-confgen is a simple preprocessor and macro system for nginx and nginx-like configuration files. It support variable substitution, macro expansion and using the output of arbitrary commands to generate config files.
Example
$certdir /etc/nginx-certificates;
pre_set
# Fetch the 'resolver' from /etc/resolv.conf
$nameserver "grep nameserver /etc/resolv.conf \\
pre_exec | head -n 1 | sed 's/^nameserver //'";
$nameserver;
resolver
# Convenient macro to create a HTTPS virtual host
$domain @aliases &block {
macro vhost
server {listen [::]:443 ssl;
$domain @aliases;
server_name
$certdir/$domain/fullchain.pem;
ssl_certificate $certdir/$domain/privkey.pem;
ssl_certificate_key -f $certdir/$domain/ocsp.der {
pre_if $certdir/$domain/ocsp.der;
ssl_stapling_file
}
█
}
}
vhost example.com www.example.com {
root /var/www/example.com; }
See the manual for more features.
Download
- Latest version
- 2.2 (2024-10-22 - nginx-confgen-2.2.tar.gz ⓘ - changes)
- Requirements
- A C compiler and a UNIX-like system. Only tested on Linux, but should also work on *BSD and MacOS (patches welcome if this is not the case).
- License
- MIT
- Distribution packages
- nginx-confgen is available in Debian.
- Development version
-
git clone https://code.blicky.net/yorhel/nginx-confgen.git
The git repository is also available for online browsing.