From 969446ca0403a0c8d37d636298ba2dd443d341c0 Mon Sep 17 00:00:00 2001 From: Charles Pritchard Date: Fri, 27 Mar 2015 16:34:46 -0700 Subject: [PATCH 1/7] Use full path of nginx executable --- bin/compile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/compile b/bin/compile index e21c7aa..0c712d5 100755 --- a/bin/compile +++ b/bin/compile @@ -125,6 +125,6 @@ cat <"$BUILD_DIR/start_nginx" #!/usr/bin/env bash rm -f /app/nginx/nginx.conf erb /app/nginx/nginx.conf.erb > /app/nginx/nginx.conf -exec nginx -p /app/nginx -c /app/nginx/nginx.conf +exec /app/nginx/nginx -p /app/nginx -c /app/nginx/nginx.conf EOF chmod +x "$BUILD_DIR/start_nginx" From 29bc30b8d3f5d0f88f6ad0d9a92a2303804ac66a Mon Sep 17 00:00:00 2001 From: Paul Caselton Date: Fri, 3 Jul 2015 22:23:06 +0100 Subject: [PATCH 2/7] Check for user defined nginx config --- bin/compile | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/bin/compile b/bin/compile index e21c7aa..78c4f7f 100755 --- a/bin/compile +++ b/bin/compile @@ -108,11 +108,17 @@ fi cd $CUR_DIR -# build nginx config unless overridden by user -#if [ ! -f $BUILD_DIR/nginx/nginx.conf ] ; then -echo "-----> using default nginx.conf.erb" -cp conf/nginx.conf.erb $BUILD_DIR/nginx/nginx.conf.erb -#fi + +# Test for user override on nginx config... +if [ -f $BUILD_DIR/nginx.conf.erb ] ; then + echo "-----> using user provided nginx.conf.erb" + cp $BUILD_DIR/nginx.conf.erb $BUILD_DIR/nginx/nginx.conf.erb + +# ...else, force default file +else + echo "-----> using default nginx.conf.erb" + cp conf/nginx.conf.erb $BUILD_DIR/nginx/nginx.conf.erb +fi # build mime.types unless overridden by user #if [ ! -f $BUILD_DIR/mime.types ] ; then From ebbc9098d98589545c3bcdfc5454c585464bfcf2 Mon Sep 17 00:00:00 2001 From: Paul Caselton Date: Sat, 4 Jul 2015 23:04:54 +0100 Subject: [PATCH 3/7] Fixing nginx user override. --- bin/compile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/compile b/bin/compile index 78c4f7f..4833af9 100755 --- a/bin/compile +++ b/bin/compile @@ -26,6 +26,8 @@ if [[ ! -e "$BUILD_DIR/www" ]]; then mv $BUILD_DIR/* $CACHE_DIR/www mkdir -p $BUILD_DIR/www mv $CACHE_DIR/www/* $BUILD_DIR/www + # Check for an copy the nginx conf file override to the build dir + [[ -f "$BUILD_DIR/www/nginx.conf.erb" ]] && mv $BUILD_DIR/www/nginx.conf.erb $BUILD_DIR [[ -f "$BUILD_DIR/www/CHECKS" ]] && mv $BUILD_DIR/www/CHECKS $BUILD_DIR rm -rf $CACHE_DIR/www fi @@ -113,6 +115,7 @@ cd $CUR_DIR if [ -f $BUILD_DIR/nginx.conf.erb ] ; then echo "-----> using user provided nginx.conf.erb" cp $BUILD_DIR/nginx.conf.erb $BUILD_DIR/nginx/nginx.conf.erb + rm $BUILD_DIR/nginx.conf.erb # ...else, force default file else From 23e4a8ab426a8e9b6f773d390ddbf3d1fd838b97 Mon Sep 17 00:00:00 2001 From: Paul Caselton Date: Sat, 4 Jul 2015 23:51:02 +0100 Subject: [PATCH 4/7] Removing rm line --- bin/compile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/compile b/bin/compile index 4833af9..eea3478 100755 --- a/bin/compile +++ b/bin/compile @@ -115,7 +115,7 @@ cd $CUR_DIR if [ -f $BUILD_DIR/nginx.conf.erb ] ; then echo "-----> using user provided nginx.conf.erb" cp $BUILD_DIR/nginx.conf.erb $BUILD_DIR/nginx/nginx.conf.erb - rm $BUILD_DIR/nginx.conf.erb + #rm $BUILD_DIR/nginx.conf.erb # ...else, force default file else From caa17b7718de1dbcb3ba360bd08d82c8894bb6e4 Mon Sep 17 00:00:00 2001 From: Paul C Date: Thu, 10 Sep 2015 18:57:55 +0100 Subject: [PATCH 5/7] Testing paths from other pack. --- bin/compile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bin/compile b/bin/compile index eea3478..adc4a40 100755 --- a/bin/compile +++ b/bin/compile @@ -108,6 +108,12 @@ else cp -r $CACHE_DIR/bin/* $BUILD_DIR/nginx/ fi +# Update the PATH +mkdir -p $BUILD_DIR/.profile.d +cat > $BUILD_DIR/.profile.d/nginx.sh <<"EOF" +export PATH="$PATH:$HOME/nginx" +EOF + cd $CUR_DIR From 69e450813edba6b316328b7f14734c245b8bf9fb Mon Sep 17 00:00:00 2001 From: Blake Kostner Date: Mon, 5 Oct 2015 17:03:08 -0700 Subject: [PATCH 6/7] added ROOT param --- conf/nginx.conf.erb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/conf/nginx.conf.erb b/conf/nginx.conf.erb index 2189ddb..82e8b4d 100644 --- a/conf/nginx.conf.erb +++ b/conf/nginx.conf.erb @@ -13,7 +13,11 @@ http { server { listen <%= ENV["PORT"] %>; server_name _; - root /app/www; + <% if ENV["ROOT"] %> + root /app/www/<%= ENV["ROOT"] %>; + <% else %> + root /app/www; + <% end %> index index.html; } } From 624cd06847232804881e91ef0b705b7cb29e788b Mon Sep 17 00:00:00 2001 From: Nick Portokallidis Date: Fri, 30 Oct 2015 13:56:00 +0200 Subject: [PATCH 7/7] Add documentation for nginx custom configuration --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index dd226ac..1f5b03a 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,9 @@ This buildpack has been successfully run on Digital Ocean instances of Ubuntu 14 All static files that you want to serve should be in the root directory of your repository. No need to use a seperate `www` folder. `buildpack-nginx` will automatically download the buildpack, download NGINX, compile it, and install it. The next time you push your project, the buildpack will reuse the precompiled binaries. +## NGINX CONFIGURATION +Override default configuration by adding `nginx.conf.erb` in the root directory + ## Credits and License `buildpack-nginx` is licensed under the CC0 1.0 Universal license and has been informed by many similar projects on the web