Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@

set -e

BIN_DIR=$(cd $(dirname $0); pwd) # absolute path
ROOT_DIR=$(dirname $BIN_DIR)
mkdir -p "$1/bin/"
cp "bin/nginx-$STACK" "$1/bin/nginx"
nginx_version=$(./bin/nginx-$STACK -V 2>&1 | head -1 | awk '{ print $NF }')
cp "${ROOT_DIR}/bin/nginx-hmrc" "$1/bin/nginx"
nginx_version=$(${ROOT_DIR}/bin/nginx-$STACK -V 2>&1 | head -1 | awk '{ print $NF }')
echo "-----> nginx-buildpack: Installed ${nginx_version} to app/bin"
cp bin/start-nginx "$1/bin/"
cp ${ROOT_DIR}/bin/start-nginx "$1/bin/"
echo '-----> nginx-buildpack: Added start-nginx to app/bin'

mkdir -p "$1/config"

cp config/mime.types "$1/config/"
cp ${ROOT_DIR}/config/mime.types "$1/config/"
echo '-----> nginx-buildpack: Default mime.types copied to app/config/'

if [[ ! -f $1/config/nginx.conf.erb ]]; then
cp config/nginx.conf.erb "$1/config/"
cp ${ROOT_DIR}/config/nginx.conf.erb "$1/config/"
echo '-----> nginx-buildpack: Default config copied to app/config.'
else
echo '-----> nginx-buildpack: Custom config found in app/config.'
Expand Down
Binary file added bin/nginx-hmrc
Binary file not shown.
18 changes: 13 additions & 5 deletions bin/start-nginx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,23 @@ do
done

#Initialize log directory.
mkdir -p logs/nginx
touch logs/nginx/access.log logs/nginx/error.log
mkdir logs
touch logs/access.log logs/error.log
echo 'buildpack=nginx at=logs-initialized'

#Start log redirection.
#Start access log redirection.
(
#Redirect NGINX logs to stdout.
tail -qF -n 0 logs/nginx/*.log
echo 'logs' >$psmgr
tail -qF -n 0 logs/access.log
echo 'access_logs' >$psmgr
) &

#Start error log redirection.
(
#Redirect NGINX logs to stdout.
tail -qF -n 0 logs/error.log | \
python -uc $'import os\nimport json\nimport sys\nfor line in sys.stdin: print(json.dumps({"app": os.getenv("APP", "unknown"), "error": line}))'
echo 'error_logs' >$psmgr
) &

#Start App Server
Expand Down
4 changes: 2 additions & 2 deletions config/nginx.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ http {
server_tokens off;

log_format l2met 'measure#nginx.service=$request_time request_id=$http_x_request_id';
access_log logs/nginx/access.log l2met;
error_log logs/nginx/error.log;
access_log logs/access.log l2met;
error_log logs/error.log;

include mime.types;
default_type application/octet-stream;
Expand Down
1 change: 1 addition & 0 deletions repository.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
repoVisibility: public_0C3F0CE3E6E6448FAD341E7BFA50FCD333E06A20CFF05FCACE61154DDBBADF71
34 changes: 15 additions & 19 deletions scripts/build_nginx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@
# Once the dyno has is 'up' you can open your browser and navigate
# this dyno's directory structure to download the nginx binary.

NGINX_VERSION=${NGINX_VERSION-1.5.7}
NGINX_VERSION=${NGINX_VERSION-1.8.0}
PCRE_VERSION=${PCRE_VERSION-8.21}
HEADERS_MORE_VERSION=${HEADERS_MORE_VERSION-0.23}
OPEN_SSL_VERSION=${OPEN_SSL_VERSION-1.0.2d}

nginx_tarball_url=http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
pcre_tarball_url=http://garr.dl.sourceforge.net/project/pcre/pcre/${PCRE_VERSION}/pcre-${PCRE_VERSION}.tar.bz2
headers_more_nginx_module_url=https://github.com/agentzh/headers-more-nginx-module/archive/v${HEADERS_MORE_VERSION}.tar.gz
ssl_tarball_url=https://www.openssl.org/source/openssl-${OPEN_SSL_VERSION}.tar.gz

temp_dir=$(mktemp -d /tmp/nginx.XXXXXXXXXX)

echo "Serving files from /tmp on $PORT"
cd /tmp
python -m SimpleHTTPServer $PORT &
temp_dir=$(mktemp -d /tmp/nginx.XXXXXXXXXX)

cd $temp_dir
echo "Temp dir: $temp_dir"
Expand All @@ -35,17 +34,14 @@ echo "Downloading $pcre_tarball_url"
echo "Downloading $headers_more_nginx_module_url"
(cd nginx-${NGINX_VERSION} && curl -L $headers_more_nginx_module_url | tar xvz )

(
cd nginx-${NGINX_VERSION}
./configure \
--with-pcre=pcre-${PCRE_VERSION} \
--prefix=/tmp/nginx \
--add-module=/${temp_dir}/nginx-${NGINX_VERSION}/headers-more-nginx-module-${HEADERS_MORE_VERSION}
make install
)

while true
do
sleep 1
echo "."
done
echo "Downloading $ssl_tarball_url"
(cd nginx-${NGINX_VERSION} && curl -L $ssl_tarball_url | tar xvz )

cd nginx-${NGINX_VERSION}
./configure \
--with-pcre=pcre-${PCRE_VERSION} \
--prefix=/tmp/nginx \
--add-module=/${temp_dir}/nginx-${NGINX_VERSION}/headers-more-nginx-module-${HEADERS_MORE_VERSION} \
--with-http_ssl_module --with-openssl=./openssl-${OPEN_SSL_VERSION}
make -j1 install