Setup a nginx reverse proxy with docker.

A reverse proxy server is a type of proxy server that typically sits behind the firewall in a private network and directs client requests to the appropriate backend server. A reverse proxy provides an additional level of abstraction and control to ensure the smooth flow of network traffic between clients and servers.

Why do we need to do this?

  • Assume you are running multiple servers on different ports on your localhost.

Here’s a visualization of what we are trying to do.

Flow Diagram


So let’s get started.

1. Project Structure

Folder Structure

2. Docker Compose file

  • At first, we are naming our docker process with the name web:.

3. Nginx Configuration file

  • We define the hostname which is localhost and the default HTTP port 80.
custom index.html

🍺 ➡️ 🧑‍💻