The Problem
I'm creating a docker image which dynamically creates nginx config based on environment variables. I would like to minimise the number of environment variables required.
I have a config template file that looks something like this:
server {
...
$ALLOW_DENY
...
}
And I'd like to configure the template like this
export ALLOW_DENY="allow 11.11.11.11; deny all;"
envsubst '\$ALLOW_DENY' < sites-available/site.template > sites-available/my-site
My problem is that I don't want to create multiple environment variables for each allow or deny statement (some configurations of this file might require none, where others might require 5 or 6) but I can't find a way to make envsubst
accept newline characters, and I'm not sure if multiple nginx commands are allowed on a single line.
For reference, I'm going to be loading all my environment variables using aws ssm
and I don't think it accepts multi-line environment variables like this:
export $ALLOW_DENY=" allow 11.11.11.11;
deny all;"
tl;dr
Is this valid?
server {
...
allow 11.11.11.11; deny all;
...
}