From 3fdbe628591256ea88beea5f39f5fb5af2120a8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Mass=C3=A9?= Date: Tue, 6 Feb 2018 18:50:58 +0100 Subject: [PATCH] nginx now starts ! --- .s2i/bin/assemble | 3 +-- .s2i/bin/run | 9 +++++++-- nginx.conf | 17 ----------------- nginx.d/sso-proxy.conf | 24 ------------------------ nginx.env.conf | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 41 insertions(+), 45 deletions(-) delete mode 100644 nginx.conf delete mode 100644 nginx.d/sso-proxy.conf create mode 100644 nginx.env.conf diff --git a/.s2i/bin/assemble b/.s2i/bin/assemble index 8a33d8e..1d2b6b6 100755 --- a/.s2i/bin/assemble +++ b/.s2i/bin/assemble @@ -7,8 +7,7 @@ set -e cd /tmp/src echo "Install nginx configuration files..." -cp nginx.d/*.conf $NGINX_CONFIGURATION_PATH/ -cp nginx.conf $APP_ROOT/etc/ +cp nginx.env.conf $APP_ROOT/etc/ echo "Creating empty dirs to hold serving certs and trusted CAs..." mkdir -p $APP_ROOT/etc/serving-cert/ $APP_ROOT/etc/ca-certs/ diff --git a/.s2i/bin/run b/.s2i/bin/run index d86092a..b13bc09 100755 --- a/.s2i/bin/run +++ b/.s2i/bin/run @@ -1,10 +1,15 @@ #!/bin/bash -source /opt/app-root/etc/generate_container_user +test -f /opt/app-root/etc/generate_container_user && source /opt/app-root/etc/generate_container_user set -e # Default values are set here export "LOG_LEVEL=${LOG_LEVEL:=info}" +export "NGINX_CONF=${NGINX_CONF:=/opt/app-root/etc/}" -exec nginx -g "daemon off;" -c "/opt/app-root/etc/nginx.conf" +if [ -f "$NGINX_CONF/nginx.env.conf" ]; then + envsubst '$LOG_LEVEL:$RESOLVER:$APP_ROOT:$SSO_SERVICE_HOSTNAME:$PROXY_ROUTE_HOSTNAME' < "$NGINX_CONF/nginx.env.conf" > "$NGINX_CONF/nginx.conf" +fi + +exec nginx -g "daemon off;" -c "$NGINX_CONF/nginx.conf" diff --git a/nginx.conf b/nginx.conf deleted file mode 100644 index 89a6c48..0000000 --- a/nginx.conf +++ /dev/null @@ -1,17 +0,0 @@ -worker_processes 1; -env $LOG_LEVEL; -error_log stderr ${LOG_LEVEL}; - -events { - worker_connections 1024; -} - -http { - include mime.types; - default_type text/plain; - sendfile on; - keepalive_timeout 65; -} - -include nginx.d/*.conf; - diff --git a/nginx.d/sso-proxy.conf b/nginx.d/sso-proxy.conf deleted file mode 100644 index b5946a0..0000000 --- a/nginx.d/sso-proxy.conf +++ /dev/null @@ -1,24 +0,0 @@ -env PROXY_ROUTE_HOSTNAME; -env APP_ROOT; -env RESOLVER; -env SSO_SERVICE_HOSTNAME; - -resolver ${RESOLVER} ipv6=off; - -server { - listen 8443 ssl; - server_name ${PROXY_ROUTE_HOSTNAME}; - - ssl on; - ssl_certificate ${APP_ROOT}/etc/serving-cert/tls.crt; - ssl_certificate_key ${APP_ROOT}/etc/serving-cert/tls.key; - - location / { - proxy_pass http://${SSO_SERVICE_HOSTNAME}; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - } -} - diff --git a/nginx.env.conf b/nginx.env.conf new file mode 100644 index 0000000..1761c8f --- /dev/null +++ b/nginx.env.conf @@ -0,0 +1,33 @@ +error_log stderr ${LOG_LEVEL}; + +worker_processes 1; + +events { + worker_connections 1024; +} + +http { + default_type text/plain; + sendfile on; + keepalive_timeout 65; + resolver ${RESOLVER} ipv6=off; + + server { + listen 8443 ssl; + server_name ${PROXY_ROUTE_HOSTNAME}; + + ssl on; + ssl_certificate ${APP_ROOT}/etc/serving-cert/tls.crt; + ssl_certificate_key ${APP_ROOT}/etc/serving-cert/tls.key; + + location / { + proxy_pass http://${SSO_SERVICE_HOSTNAME}; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + } +} + +