Blog
November 25, 2015 Marie H.

Setting up ElasticBeanStalk environment for WSGI authorization

Setting up ElasticBeanStalk environment for WSGI authorization

Photo by <a href="https://unsplash.com/@zulfugarkarimov?utm_source=cloudista&utm_medium=referral" target="_blank" rel="noopener">Zulfugar Karimov</a> on <a href="https://unsplash.com/?utm_source=cloudista&utm_medium=referral" target="_blank" rel="noopener">Unsplash</a>

Recently, I discussed an issue with JWT tokens not being recognized when deploying my API from a standard EC2 instance to a EBS instance.

Where I explained how you could manually modify the environment; now obviously this is not the proper way to handle this issue as with each new deployment you would need to login to the server and reconfigure Apache.

So in order to prevent this additional work here is how you would setup WSGI Authorization automagically with each deploy:

  • In your virtualenv application path run the following
mkdir .ebextensions
  • Make a configuration file to be read on each deployment
touch .ebextensions/wsgi_enabled_pass.config
  • Add configuration
container_commands:
   01_wsgipass:
     command: 'echo "WSGIPassAuthorization On" >> ../wsgi.conf'

This does what you expect it to do executing the command echo and appending the configuration to wsgi.conf file in your Apache home directory.

For more information please see: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-configuration-methods-before.html#configuration-options-before-ebextensions