Skip to content
A demonstration of running a multiple instances of a web service behind an nginx reverse proxy with dynamic configuration
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Horizontally scaling a web service

Docker hub stars Docker hub pulls Build Status

This repository demonstrates how you can run a trivial web service that can be run in parallel behind a reverse proxy, and distribute requests accross multiple concurrent instances of the web service. In this case nginx functions as our reverse proxy and we use docker-gen to dynamically configure nginx to change upstream configuration of the server which handles request distribution across the concurrent web service instances.

How to play

Install docker (ideally on linux, otherwise you'll struggle with an additional layer of virtual machine networking to route through)

  • Start the containers
$ docker-compose up
  • Inspect the reverse proxy configuration
$ docker exec cat $PROXY_CONTAINER_NAME /etc/nginx/conf.d/default.conf
  • Scale the number of web services
$ docker-compose prime_server=5
  • Inspect the reverse proxy configuration
$ docker exec cat $PROXY_CONTAINER_NAME /etc/nginx/conf.d/default.conf
You can’t perform that action at this time.