From b7989d1ea1ead8516838ce3c6bef58fca5083323 Mon Sep 17 00:00:00 2001 From: Choucri FAHED Date: Tue, 12 May 2020 18:33:38 +0200 Subject: [PATCH] Replace P6 Proxy by Nginx --- docker-compose/deploy/app-developer/.env | 1 - .../deploy/app-developer/docker-compose.yml | 21 ++++++--------- docker-compose/deploy/demobc-developer/.env | 1 - .../demobc-developer/docker-compose.yml | 21 ++++++--------- docker-compose/reference/proxy.conf | 27 +++++++++++++++++++ docker-compose/scripts/proxy_healthcheck.sh | 13 --------- 6 files changed, 43 insertions(+), 41 deletions(-) create mode 100644 docker-compose/reference/proxy.conf delete mode 100755 docker-compose/scripts/proxy_healthcheck.sh diff --git a/docker-compose/deploy/app-developer/.env b/docker-compose/deploy/app-developer/.env index b919b3a..88d875d 100644 --- a/docker-compose/deploy/app-developer/.env +++ b/docker-compose/deploy/app-developer/.env @@ -2,7 +2,6 @@ PGSQL_VERSION=11.7-alpine P6CORE_IMAGE_ID=amalto/platform6 P6CORE_VERSION=latest P6CORE_DATA=p6core.data -PROXY_ENV=prod INSTANCE_ID=unnamed PLATFORM6_DATA_PATH=~/platform6/instances CLIENT_ID=client-id-in-here diff --git a/docker-compose/deploy/app-developer/docker-compose.yml b/docker-compose/deploy/app-developer/docker-compose.yml index a952278..decbb76 100644 --- a/docker-compose/deploy/app-developer/docker-compose.yml +++ b/docker-compose/deploy/app-developer/docker-compose.yml @@ -57,24 +57,19 @@ services: retries: 5 start_period: 5m - p6proxy: - container_name: p6proxy - image: amalto/p6proxy + proxy: + container_name: proxy + image: nginx:1.18-alpine + depends_on: + - p6core volumes: - - ../../scripts/proxy_healthcheck.sh:/opt/proxy_healthcheck.sh:ro - environment: - - PROXY_PLAIN_PORT=8480 - - PROXY_SSL_PORT=8483 - - LOG_FORMAT=string - - LOG_LEVEL=5 - - PROXY_NO_SSL=false - - PROXY_NO_CACHE=true - - PROXY_ENV=${PROXY_ENV} + - ../../reference/proxy.conf:/etc/nginx/conf.d/proxy.conf:ro + - ${PLATFORM6_DATA_PATH}/${INSTANCE_ID}/nginx/logs:/var/log/nginx:delegated ports: - "8480:8480" - "8483:8483" healthcheck: - test: ["CMD", "/opt/proxy_healthcheck.sh"] + test: ["CMD", "wget", "-q", "-O", "-", "http://localhost:8480"] interval: 10s timeout: 30s retries: 5 diff --git a/docker-compose/deploy/demobc-developer/.env b/docker-compose/deploy/demobc-developer/.env index b919b3a..88d875d 100644 --- a/docker-compose/deploy/demobc-developer/.env +++ b/docker-compose/deploy/demobc-developer/.env @@ -2,7 +2,6 @@ PGSQL_VERSION=11.7-alpine P6CORE_IMAGE_ID=amalto/platform6 P6CORE_VERSION=latest P6CORE_DATA=p6core.data -PROXY_ENV=prod INSTANCE_ID=unnamed PLATFORM6_DATA_PATH=~/platform6/instances CLIENT_ID=client-id-in-here diff --git a/docker-compose/deploy/demobc-developer/docker-compose.yml b/docker-compose/deploy/demobc-developer/docker-compose.yml index c5d8d1c..49c34c3 100644 --- a/docker-compose/deploy/demobc-developer/docker-compose.yml +++ b/docker-compose/deploy/demobc-developer/docker-compose.yml @@ -58,24 +58,19 @@ services: retries: 5 start_period: 5m - p6proxy: - container_name: p6proxy - image: amalto/p6proxy + proxy: + container_name: proxy + image: nginx:1.18-alpine + depends_on: + - p6core volumes: - - ../../scripts/proxy_healthcheck.sh:/opt/proxy_healthcheck.sh:ro - environment: - - PROXY_PLAIN_PORT=8480 - - PROXY_SSL_PORT=8483 - - LOG_FORMAT=string - - LOG_LEVEL=5 - - PROXY_NO_SSL=false - - PROXY_NO_CACHE=true - - PROXY_ENV=${PROXY_ENV} + - ../../reference/proxy.conf:/etc/nginx/conf.d/proxy.conf:ro + - ${PLATFORM6_DATA_PATH}/${INSTANCE_ID}/nginx/logs:/var/log/nginx:delegated ports: - "8480:8480" - "8483:8483" healthcheck: - test: ["CMD", "/opt/proxy_healthcheck.sh"] + test: ["CMD", "wget", "-q", "-O", "-", "http://localhost:8480"] interval: 10s timeout: 30s retries: 5 diff --git a/docker-compose/reference/proxy.conf b/docker-compose/reference/proxy.conf new file mode 100644 index 0000000..8d74a2c --- /dev/null +++ b/docker-compose/reference/proxy.conf @@ -0,0 +1,27 @@ +server { + server_name _; + listen 8480; + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log debug; + + if ($arg_baseUrl) { + rewrite ^(.*)$ /baseUrl/$1; + } + + location ~ /baseUrl/ { + resolver 127.0.0.11 ipv6=off; + proxy_pass $arg_baseUrl$request_uri; + } + + location ~ /hawtio { + proxy_pass http://p6core:8080; + } + + location ~ /p6/vmstats { + proxy_pass http://p6core:8080; + } + + location ~ / { + proxy_pass http://portalbucket.amalto.com; + } +} diff --git a/docker-compose/scripts/proxy_healthcheck.sh b/docker-compose/scripts/proxy_healthcheck.sh deleted file mode 100755 index f9540fb..0000000 --- a/docker-compose/scripts/proxy_healthcheck.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -echo "p6proxy: healthcheck" - -wget -q -O - http://p6proxy:8480 2>&1 | grep 400 > /dev/null - -if [ "$?" = "0" ]; then - echo "Health is Good"; - exit 0; -else - echo "Health is Bad!"; - exit 1; -fi