From ce961bb5865b5d16d203365159ab173e67e34556 Mon Sep 17 00:00:00 2001
From: Alex Xu <alex_y_xu@yahoo.ca>
Date: Sun, 18 Aug 2013 12:09:30 -0400
Subject: fix nginx.* to work better with slim nginx

also print warning if zopfli is not found
---
 nginx.conf          |  7 ++-----
 nginx.sh            | 36 ++++++++++++++++++++++++++++++++----
 unrpyc/find-gzip.sh |  4 ++++
 3 files changed, 38 insertions(+), 9 deletions(-)

diff --git a/nginx.conf b/nginx.conf
index c0a88bd..0576dbd 100644
--- a/nginx.conf
+++ b/nginx.conf
@@ -7,13 +7,11 @@ error_log /dev/null;
 
 http {
 
+  include nginx.gen.conf;
+
   access_log /dev/null;
   error_log stderr info;
   client_body_temp_path /dev/null;
-  proxy_temp_path /dev/null;
-  fastcgi_temp_path /dev/null;
-  scgi_temp_path /dev/null;
-  uwsgi_temp_path /dev/null;
 
   types {
     application/font-woff woff;
@@ -37,7 +35,6 @@ http {
   default_type application/octet-stream;
 
   gzip on;
-  include nginx.gen.conf;
   gzip_types application/javascript application/json image/svg+xml text/plain text/css;
   gzip_vary on;
 
diff --git a/nginx.sh b/nginx.sh
index e00f519..089bc67 100755
--- a/nginx.sh
+++ b/nginx.sh
@@ -1,8 +1,36 @@
-#!/bin/sh
-cd "`dirname $0`"
+#!/bin/bash
+
+set -e
+cd "$(dirname $0)"
+
+
 # empty file
 > nginx.gen.conf
-if nginx -V 2>&1 | grep -q -- --with-http_gzip_static_module; then
-  echo "gzip_static on" >> nginx.gen.conf
+
+
+V=$(nginx -V 2>&1)
+
+if echo ${V} | grep -q -- --with-http_gzip_static_module; then
+  echo "gzip_static on;" >> nginx.gen.conf
+else
+  echo >&2 "The gzip_static module for nginx is highly recommended to reduce server load and utilize zopfli's higher compression ratio."
 fi
+
+if ! echo ${V} | grep -q -- --without-http_proxy_module; then
+  echo "proxy_temp_path /dev/null;" >> nginx.gen.conf
+fi
+
+if ! echo ${V} | grep -q -- --without-http_fastcgi_module; then
+  echo "fastcgi_temp_path /dev/null;" >> nginx.gen.conf
+fi
+
+if ! echo ${V} | grep -q -- --without-http_scgi_module; then
+  echo "scgi_temp_path /dev/null;" >> nginx.gen.conf
+fi
+
+if ! echo ${V} | grep -q -- --without-http_uwsgi_module; then
+  echo "uwsgi_temp_path /dev/null;" >> nginx.gen.conf
+fi
+
+
 exec nginx -p "$PWD" -c nginx.conf
diff --git a/unrpyc/find-gzip.sh b/unrpyc/find-gzip.sh
index 26e60c0..2ee9064 100755
--- a/unrpyc/find-gzip.sh
+++ b/unrpyc/find-gzip.sh
@@ -4,7 +4,11 @@ GZIP="$(command -v gzip)"
 if [ -n $ZOPFLI ]; then
   echo "$ZOPFLI"
 elif [ -n $GZIP ]; then
+  echo >&2 "Consider obtaining zopfli (https://code.google.com/p/zopfli/)"
+  echo >&2 "for higher compression ratios (about 5% decrease in size of"
+  echo >&2 "script.json.gz."
   echo "$GZIP -9"
 else
+  echo >&2 "Could not find zopfli or gzip, aborting."
   exit 1
 fi
-- 
cgit v1.2.3-70-g09d2