forked from heroku/heroku-buildpack-nginx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_nginx
executable file
·68 lines (56 loc) · 2.62 KB
/
build_nginx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
# Build NGINX and modules on Heroku.
# This program is designed to run in a web dyno provided by Heroku.
# We would like to build an NGINX binary for the builpack on the
# exact machine in which the binary will run.
# Our motivation for running in a web dyno is that we need a way to
# download the binary once it is built so we can vendor it in the buildpack.
#
# 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.22.0}
NAXSI_VERSION=${NAXSI_VERSION-1.2}
PCRE_VERSION=${PCRE_VERSION-8.43}
HEADERS_MORE_VERSION=${HEADERS_MORE_VERSION-0.34}
ZLIB_VERSION=${ZLIB_VERSION-1.2.12}
UUID4_VERSION=${UUID4_VERSION-master}
nginx_tarball_url=http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
pcre_tarball_url=http://downloads.sourceforge.net/project/pcre/pcre/${PCRE_VERSION}/pcre-${PCRE_VERSION}.tar.bz2
headers_more_nginx_module_url=https://github.com/openresty/headers-more-nginx-module/archive/v${HEADERS_MORE_VERSION}.tar.gz
uuid4_url=https://github.com/cybozu/nginx-uuid4-module/archive/${UUID4_VERSION}.tar.gz
zlib_url=http://zlib.net/zlib-${ZLIB_VERSION}.tar.gz
naxsi_url=https://github.com/nbs-system/naxsi/archive/${NAXSI_VERSION}.tar.gz
temp_dir=$(mktemp -d /tmp/nginx.XXXXXXXXXX)
cd $temp_dir
echo "Temp dir: $temp_dir"
echo "Downloading $nginx_tarball_url"
curl -L $nginx_tarball_url | tar xzv
echo "Downloading $pcre_tarball_url"
(cd nginx-${NGINX_VERSION} && curl -L $pcre_tarball_url | tar xvj )
echo "Downloading $headers_more_nginx_module_url"
(cd nginx-${NGINX_VERSION} && curl -L $headers_more_nginx_module_url | tar xvz )
echo "Downloading $zlib_url"
(cd nginx-${NGINX_VERSION} && curl -L $zlib_url | tar xvz )
echo "Downloading $uuid4_url"
(cd nginx-${NGINX_VERSION} && curl -L $uuid4_url | tar xvz )
echo "Downloading $naxsi_url"
(cd nginx-${NGINX_VERSION} && curl -L $naxsi_url | tar xvz )
(
cd nginx-${NGINX_VERSION}
./configure \
--with-pcre=pcre-${PCRE_VERSION} \
--with-zlib=zlib-${ZLIB_VERSION} \
--with-http_gzip_static_module \
--with-http_realip_module \
--with-http_ssl_module \
--with-http_auth_request_module \
--prefix=/tmp/nginx \
--add-dynamic-module=${temp_dir}/nginx-${NGINX_VERSION}/headers-more-nginx-module-${HEADERS_MORE_VERSION} \
--add-dynamic-module=${temp_dir}/nginx-${NGINX_VERSION}/nginx-uuid4-module-${UUID4_VERSION} \
--add-dynamic-module=${temp_dir}/nginx-${NGINX_VERSION}/naxsi-${NAXSI_VERSION}/naxsi_src/ \
--without-mail_imap_module \
--without-mail_pop3_module \
--without-mail_smtp_module
make install
)
cp /tmp/nginx/sbin/nginx $1