There are many ways to parse in variable into the nginx config file.
Some uses set_by_lua
which is offered by lua-nginx-module.
Some use envstubst
to populate varilabes into a template file.
Today I am going to show you how to do that with njs
the JS scripting engine for nginx.
## /etc/nginx/fetch_env.js
function fetch_upstream_host(r) {
return process.env.UPSTREAM_HOST;