Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Customize AWS Elastic Beanstalk wsgi.conf without being wiped out after update of environment variables
"/opt/elasticbeanstalk/hooks/configdeploy/pre/": &file
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env python
import os
import sys
import config
def main():
if 'EB_SYSTEM_STARTUP' in os.environ:
WSGI_STAGING_CONFIG = config.get_container_config('wsgi_staging_config')
config.execute(['mkdir', '-p', '/etc/httpd/wsgi.conf.d'])
config.execute(['sed', '-i', '/\<VirtualHost \*:80\>/a IncludeOptional /etc/httpd/wsgi.conf.d/*.conf', WSGI_STAGING_CONFIG])
except Exception, e:
config.diagnostic('Error patching wsgi.conf during configdeploy/pre: %s' % str(e))
if __name__ == '__main__':
"/opt/elasticbeanstalk/hooks/appdeploy/pre/": *file
mode: "000755"
owner: root
group: root
content: |
WSGIPassAuthorization On

This comment has been minimized.

Copy link
Owner Author

@djshen-ponddy djshen-ponddy commented Oct 13, 2017

This script will create two hook files:
and will be executed during app deploy or config update.

We can put customized apache configs that must be inside VirtualHost, for example, enable_auth_header.conf,
in /etc/httpd/wsgi.conf.d directory, and the config files will be included by IncludeOptional /etc/httpd/wsgi.conf.d*.conf.


This comment has been minimized.

Copy link

@michealjroberts michealjroberts commented Oct 23, 2019

Is there a way to use this to force http => https redirects?


This comment has been minimized.

Copy link

@ankitbeohar90 ankitbeohar90 commented Dec 17, 2019

@djshen-ponddy can you elaborate steps how to deploy this script and will it be applicable in autoscale case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment