Skip to content

Instantly share code, notes, and snippets.

@bitmage
Created February 7, 2017 03:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitmage/8e7a56cb1c493456345a85b044276ff6 to your computer and use it in GitHub Desktop.
Save bitmage/8e7a56cb1c493456345a85b044276ff6 to your computer and use it in GitHub Desktop.
Replace ENV variables in an nginx config. Minimal solution - a perl one liner!
#!/bin/sh
perl -pe 's/\$\{([^}]+)\}/defined $ENV{$1} ? $ENV{$1} : die("Missing env variable: $1")/eg' \
< /src/proxy-redirect.conf >/etc/nginx/conf.d/nginx.conf \
&& nginx -g 'daemon off;'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment