Using NGINX as an API Gateway
In Chapter 4, Building the Microservice Application, we implemented the API Gateway design pattern using only some FastAPI components. In this last chapter, we will build a reverse proxy server through NGINX that will assign a proxy IP address to each containerized microservice application. These proxy IPs will redirect client requests to the actual microservices running on their respective containers.
Instead of building an actual NGINX environment, we will be pulling an available NGINX image from Docker Hub to implement the reverse proxy server. This image creation requires a new Docker app folder with a different Dockerfile
containing the following instructions:
FROM nginx:latest COPY ./nginx_config.conf /etc/nginx/conf.d/default.conf
The Dockerfile
instructs the creation of the latest NGINX image and a copy of a nginx_config.conf
file to that image. The file is an NGINX configuration file that contains the mapping of a proxy IP address to...