Skip to content
Example Nginx setup using Docker, with integration tests
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dnsmasq
gatling
lib
muxy
nginx-config.d
scripts
test
Dockerfile
LICENSE
README.md
docker-compose.yml
nginx.conf

README.md

Domain Router

An example Nginx router setup, using Docker, complete with integration tests and resilience testing using Muxy.

TOC

Setup

Install & Setup Docker

  • Install Docker and Docker Machine
  • Build and run the image
docker-compose build && docker-compose up

This should spin up Nginx, DNSMasq and a test API (echo server). You can now hit the API at curl -v -H"Host: api.foo.com" <dockerhost>:8001/header/host. Note that we have to pass through the host header with the request.

Testing

Integration test suite for Nginx.

Running Tests

./scripts/run-tests.sh          # Run all tests
./scripts/run-tests integration # Run just the integration tests

Test Setup

To be able to run the Nginx router locally, and also to be able to test the configuration, we use dnsmasq in conjunction with Docker Compose.

Nginx is then configured to use dnsmasq for host resolution, allowing us to replace real systems with a Mock Service by creating host entries in the dnsmasq container. This works nicely in Production, where we don't create any host entries so the real services are resolved instead.

The components of the integration test are:

  • Nginx
  • dnsmasq - hijacks the real domain names, instructing Nginx to send traffic to our Mock Server so that we can test production configuration
  • Mock Server
  • Test Case container issuing requests against the Nginx instance

This can be visually represented as:

[Test Container] <- (issues tests to) -> [Nginx Container] <- (proxies) -> [Mock API]
                                                 ||        <- (proxies) -> [Backup API]   
                                                 ||
                                    (resolves DNS queries from)
                                                 \/
                                             [Dnsmasq]
You can’t perform that action at this time.