Open josegonzalez opened 1 year ago
Maybe something like this could work: https://gist.github.com/crisidev/3d314af9494255e24aa5f78646909ec0
We could potentially write that a single json file that contains the basic auth entries for all apps, then read that in during init_by_lua*
, set a dict block var that contains the basic auth info for a given app, then do authentication by lua to check that for applicable apps.
It would be nice to have the ability to specify basic auth. This would be done by making the
config.toml
itself dynamically generated. We'd iterate over each app, and then generate anhtpasswd
entry for each.On generation of an
htpasswd
entry, we'd want to also have something like consul-template's writeToFile function (requires forking docker-gen). This would allow us to dynamically write a template config with theapp
name in place for retrieving the correct config.I'm envisioning generating templates like the following:
We'd want to read in the above template via
include
- PR todocker-gen
here - and replace APP_NAME with the app name.Once we generate the templates, the entry for the
htpasswd
file in theconfig.toml
should have a hashed (sha256?) comment string so that we force the file to be recognized as "changed". We'd then sighup docker-gen itself.Then on
docker-gen
reload, we would writeauth_basic
andauth_basic_user_file
entries in the mainnginx.conf
file if the label has values.