Search⌘ K

Writing NGINX Configuration

Understand how to configure NGINX as a reverse proxy to route HTTP requests from port 80 to a Django app running on port 8000 inside a Docker container. Learn to define upstream servers and location blocks, launch Docker containers with Compose, and run commands inside containers. This lesson prepares you for efficient, containerized Django deployment.

We'll cover the following...

NGINX requires some configuration from our side. If there is a request on the HTTP port of the machine (by default 80), it should redirect the requests to port 8000 of the running Django application. Put simply, we will write a reverse proxy. A proxy is an intermediary process that takes an HTTP request from a client, passes the request to one or many other servers, waits for a response from those servers, and sends back a response to the client.

By using this process, we can forward a request on the HTTP port 80 to port 8000 of the Django server.

At the root of the project, create a new file called nginx.conf. Then, let’s define the upstream server ...