Skip to content

Instantly share code, notes, and snippets.

@youhide
Last active March 31, 2017 23:55
Show Gist options
  • Save youhide/1c6505dddb4a835cb10f0a091bac9edb to your computer and use it in GitHub Desktop.
Save youhide/1c6505dddb4a835cb10f0a091bac9edb to your computer and use it in GitHub Desktop.
Pass environment variable to NGINX fastcgi on AWS ElasticBeanstalk
#!/usr/bin/env bash
. /opt/elasticbeanstalk/support/envvars
cp /etc/nginx/fastcgi_params.default /etc/nginx/fastcgi_params
. /opt/elasticbeanstalk/bin/get-config environment | python -c "import json,sys; obj=json.load(sys.stdin); f = open('/etc/nginx/fastcgi_params', 'a'); f.write('\n'.join(map(lambda x: 'fastcgi_param ' + x[0] + ' ' + x[1] + ';', obj.iteritems())))"
service httpd stop
service nginx restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment