Hello
Coming from Caddy there is a feature where I can include a file passing arguments to the file, hence designing template files is very neat and straigthforward
Imagine I have 100 domains, domain1.com, domain2.com, ... domain100.com
And I want to use NGINX as a reverse proxy for such domains
How can I create a simple config, to pass the minimum text I can configure them all significantly? (including logging, expires, compression, and all the features I want)?
So far the only idea I've found is passing $server_name to all configurable parameters except for server_name and error_log and have in one file all like:
server {
include /path_to_templated elements that accept $server_name
server_name domain1.com
error_log /var/log/nginx/error-domain1.com.log;
}
server {
include /path_to_templated elements that accept $server_name
server_name domain2.com
error_log /var/log/nginx/error-domain2.com.log;
}
...
server {
include /path_to_templated elements that accept $server_name
server_name domain100.com
error_log /var/log/nginx/error-domain100.com.log;
}
From what I've read, server_name and error_log are some of the few directives that don't admit variables, hence templating like this is impossible (the only templating I've seen is designed for separate instances of Nginx passing ENV variables which I don't find too useful in this scenario because I cannot conditionally control them inside Nginx
Anyway its not terrible this way, but since I'm an Nginx newcomer I was simply wondering if there is something better than this.