#! /bin/bash
echo 'Starting nginx'
NAMESERVER=`cat /etc/resolv.conf | grep "nameserver" | awk '{print $2}' | tr '\n' ' '`
echo "resolver $NAMESERVER valid=10s;" > /conf/nginx/resolver.conf
if [ -f /conf/stack/ssl.key ]
then
echo "Using HTTPS"
/usr/sbin/nginx -c /conf/nginx/nginx.conf
else
echo "No SSL key provided, using HTTP"
/usr/sbin/nginx -c /conf/nginx/nginx-nossl.conf
fi
echo 'Nginx exited'