Skip to content

A docker image with handlebars / yq / yq and envsubst which is utilized for generating nginx configuration based on env vars and a mounted `services.yaml.tmpl` File.

License

Notifications You must be signed in to change notification settings

iilei/api-proxy

Repository files navigation

API Proxy

A docker image with handebars / yq / yq and envsubst which is utilized for generating nginx configuration based on env vars and a mounted services.yaml.tmpl File.

Get it on dockerhub

How it works

For each version of your services, environment variables which provide space-separated lists of upstreams are consumed when executing the entrypoint:

export V1_UPSTREAMS="example.com:7701 example.com:7702"

Those are inserted in services.yaml.tmpl utilizing envtpl.

After validation of the config, nginx conf files are generated with handlebars templating.

Try it out

Check the examples:

  • basic docker-compose --file examples/basic/docker-compose.yml up
  • multiple upstreams docker-compose --file examples/multiple_upstreams/docker-compose.yml up
  • rewrite docker-compose --file examples/rewrite/docker-compose.yml up
  • sunsets docker-compose --file examples/sunsets/docker-compose.yml up

Please note: The end-of-life date is solely exposed but will not be used to disable the respective upstream. Hence, to actually turn off old versions they must be taken off from the services.yaml.tpl and a restart is needed.

Check sunsetHeader.hbs and unsatisfiableVersion.hbs to learn how these messages are composed.

Advanced config

Take a look at the examples to learn more about configuration.

For further insights, check schema.json used for validation of the services config.

Customize

Create your own services.yaml and .env file, Adjust to your liking:

cp examples/basic/services.yaml.tmpl ./
cp .env.example .env

Once you have adjusted both files to your needs, run

docker run \
  --env-file=./.env \
  -v `pwd`/services.yaml.tmpl:/services.yaml.tmpl \
  -p 1731:80 \
  api-proxy

Further customization

If you want custom templates, simply mount your own hbs and nginx volumes

About

A docker image with handlebars / yq / yq and envsubst which is utilized for generating nginx configuration based on env vars and a mounted `services.yaml.tmpl` File.

Resources

License

Stars

Watchers

Forks

Packages

No packages published