I started tinkering around with the NGINX JavaScript module, but ran into a wall when trying to use environmental variables.
In /etc/nginx/nginx.conf I u
/etc/nginx/nginx.conf