A better heroku python buildpack
Heroku has a Python buildpack but it is a suboptimal in some ways.
- Gunicorn directly behind heroku router is succeptible to a ddos attack.
- The recommended static file server is static. Which is a bit of cop out. Something like nginx is much better suited for this.
- In search for Heroku's no configuration deploys, it doesn't allow setting things like the location of manage.py explicitly. To find the manage.py the buildpack is doing "MANAGE_FILE=$(find . -maxdepth 3 -type f -name 'manage.py' | head -1)". This goes against "explicit is better tha implicit" and will mean that different manage.py will be found in different heroku deploys.
What this does
To workaround this
- The buildpack installs nginx, and gunicorn is used behind nginx.
- Static files are served via nginx
- It takes a heroku.yml file which allows overriding the location of
Some other benefits you get with this
- Since you have nginx, you can take take advantage of nginx tooling. In particular, the bundled nginx comes with pagespeed enabled, which can make a signifcant impact to your forntend performance.
- You can use nginx to do rewrites. (For example to force ssl only).
- You can host things like sphinx docs in a folder, and serve it directly from nginx.