Configure the Proxy Server

Learn how to install and configure NGINX with Heroku.

Installing NGINX

NGINX is not a Python package, so it can’t be inferred from the Pipfile. Instead, we need to explicitly tell Heroku to install it using the buildpack.

$ heroku buildpacks:add heroku-community/nginx

NGINX configuration

The easiest way to set up NGINX is to serve files from a directory. However, that’s not going to be good enough here, so we need to look into customizing its configuration file. We’ll put our NGINX and Gunicorn configuration files in a new config directory at the top of the Git repository. When requests first come in, they’ll go to NGINX, so we’ll look at the nginx.conf.erb file first. Here it is, in its entirety:

Get hands-on with 1200+ tech skills courses.