From 5b0ebca03431316774ecd61f2fa1d83977b277dd Mon Sep 17 00:00:00 2001 From: Matt Fellows Date: Tue, 9 Oct 2018 10:06:43 +1100 Subject: [PATCH] example(docker): update compose example with non-HTTPs endpoint --- docker-compose.yml | 18 +++++++++++------- ssl/nginx.conf | 11 +++++++++++ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 18c7682..cae165b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,6 @@ -version: '3' +version: "3" services: - postgres: image: postgres healthcheck: @@ -15,22 +14,27 @@ services: broker_app: image: dius/pact-broker - ports: - - "80:80" links: - postgres + # If you remove nginx, enable the following + #ports: + # - "80:80" environment: PACT_BROKER_DATABASE_USERNAME: postgres PACT_BROKER_DATABASE_PASSWORD: password PACT_BROKER_DATABASE_HOST: postgres PACT_BROKER_DATABASE_NAME: postgres + # Nginx is not necessary, but demonstrates how + # one might use a reverse proxy in front of the broker, + # and includes the use of a self-signed TLS certificate nginx: image: nginx:alpine links: - broker_app:broker volumes: - - ./ssl/nginx.conf:/etc/nginx/conf.d/default.conf:ro - - ./ssl:/etc/nginx/ssl + - ./ssl/nginx.conf:/etc/nginx/conf.d/default.conf:ro + - ./ssl:/etc/nginx/ssl ports: - - "8443:443" + - "8443:443" + - "80:80" diff --git a/ssl/nginx.conf b/ssl/nginx.conf index 83eea6c..83f5a21 100644 --- a/ssl/nginx.conf +++ b/ssl/nginx.conf @@ -19,3 +19,14 @@ server { proxy_set_header X-Real-IP $remote_addr; } } + +server { + listen 80 default_server; + server_name localhost; + + location / { + proxy_pass http://broker:80; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + } +}