Python Flask webapp simple proxy configuration to enable SSL/HTTPS with Apache Python Flask webapp simple proxy configuration to enable SSL/HTTPS with Apache flask flask

Python Flask webapp simple proxy configuration to enable SSL/HTTPS with Apache


We add a line in httpd.conf that handles /static/ instead of proxying it to gunicorn:

<VirtualHost oursite.com>  # Tells apache where /static/ should go  Alias /static/ /full/path/to/flask/app/static/  # Proxy everything to gunicorn EXCEPT /static and favicon.ico  ProxyPass /favicon.ico !  ProxyPass /static !  ProxyPass / http://gunicorn.oursite.com:4242/  ProxyPassReverse / http://gunicorn.oursite.com:4242/</VirtualHost>

This works because we have gunicorn and apache running on the same box, which may or may not work for you. You might have to copy the static files to the apache host as part of your site deployment.

There's probably a better way to do it, but it works for us.