Intro to NGINX Reverse Proxy with Docker Compose

Edward Cernera
3 min readMay 10, 2020

In a previous article, I discussed how to deploy a website to Windows/Linux using React, WordPress, and NGINX containers with Docker Compose. To do this, it is necessary that Docker containers can speak to each other via the Docker network. A practical example of this, as per my referenced article, is how NGINX receives incoming client requests and communicates with the WordPress container to service those requests. This concept is known as a reverse proxying.

Photo by Daniel von Appen on Unsplash

Docker Networking

Here is a stripped example of a docker-compose.yml file that creates both an NGINX and WordPress container (simplified to relevant information only):

version: "3.2"

services:

wordpress:
image: wordpress:5.3.2-fpm-alpine
container_name: wordpress-cont
restart: unless-stopped
networks:
- app-network

nginx:
build:
context: ./web_server
dockerfile: Dockerfile
args:
react_dir: ${REACT_PROJECT_DIR:-reactapp}
container_name: nginx-cont
depends_on:
- wordpress
networks:
- app-network

networks:
app-network

We create two services: wordpress and nginx. I explicitly set the name of the Docker network to build which corresponds to this orchestration, called app-network (no functional purpose, in this case). Now, what I do not

--

--

Edward Cernera
Edward Cernera

Written by Edward Cernera

Software Engineer | I write software tutorials because I can’t find them anywhere. Creator of DealPunkk - dealpunkk.com | About Me - cernera.me/edward