| 1 | #!/bin/sh
|
|---|
| 2 | apt install zlib1g-dev zlib1g libpcre3 libpcre3-dev build-essential git wget
|
|---|
| 3 |
|
|---|
| 4 | NGINX_VER=1.15.3
|
|---|
| 5 | OPENSSL_VER=1.1.1-pre9
|
|---|
| 6 | NGINX_GPG="573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 \
|
|---|
| 7 | A09CD539B8BB8CBE96E82BDFABD4D3B3F5806B4D \
|
|---|
| 8 | 4C2C85E705DC730833990C38A9376139A524C53E \
|
|---|
| 9 | 65506C02EFC250F1B7A3D694ECF0E90B2C172083 \
|
|---|
| 10 | B0F4253373F8F6F510D42178520A9993A1C052F8 \
|
|---|
| 11 | 7338973069ED3F443F4D37DFA64FD5B17ADB39A8"
|
|---|
| 12 |
|
|---|
| 13 | echo "**** download package ****"
|
|---|
| 14 | git clone https://github.com/openresty/headers-more-nginx-module --depth=1 /tmp/headers-more-nginx-module
|
|---|
| 15 | git clone https://github.com/bagder/libbrotli --depth=1 /tmp/libbrotli
|
|---|
| 16 | git clone https://github.com/google/ngx_brotli --depth=1 /tmp/ngx_brotli
|
|---|
| 17 | wget -q http://nginx.org/download/nginx-${NGINX_VER}.tar.gz -O /tmp/nginx-${NGINX_VER}.tar.gz
|
|---|
| 18 | wget -q http://nginx.org/download/nginx-${NGINX_VER}.tar.gz.asc -O /tmp/nginx-${NGINX_VER}.tar.gz.asc
|
|---|
| 19 | wget -q https://www.openssl.org/source/openssl-${OPENSSL_VER}.tar.gz -O /tmp/openssl-${OPENSSL_VER}.tar.gz
|
|---|
| 20 | git clone https://github.com/grahamedgecombe/nginx-ct --depth=1 /tmp/nginx-ct
|
|---|
| 21 |
|
|---|
| 22 | echo "**** compile brotli ****"
|
|---|
| 23 | cd /tmp/libbrotli
|
|---|
| 24 | ./autogen.sh
|
|---|
| 25 | ./configure
|
|---|
| 26 | mkdir brotli/c/tools/.deps
|
|---|
| 27 | touch brotli/c/tools/.deps/brotli-brotli.Po
|
|---|
| 28 | make -j 1
|
|---|
| 29 | make install
|
|---|
| 30 | cd /tmp/ngx_brotli
|
|---|
| 31 | git submodule update --init
|
|---|
| 32 |
|
|---|
| 33 | echo "**** untar openssl ****"
|
|---|
| 34 | cd /tmp
|
|---|
| 35 | tar xzf openssl-${OPENSSL_VER}.tar.gz
|
|---|
| 36 |
|
|---|
| 37 | echo "**** compile nginx ****"
|
|---|
| 38 | cd /tmp
|
|---|
| 39 | for server in ha.pool.sks-keyservers.net hkp://keyserver.ubuntu.com:80 hkp://p80.pool.sks-keyservers.net:80 pgp.mit.edu;
|
|---|
| 40 | do
|
|---|
| 41 | echo "Fetching GPG key $NGINX_GPGKEY from $server";
|
|---|
| 42 | gpg --keyserver "$server" --keyserver-options timeout=10 --recv-keys $NGINX_GPG && found=yes && break;
|
|---|
| 43 | done
|
|---|
| 44 | gpg --batch --verify nginx-${NGINX_VER}.tar.gz.asc nginx-${NGINX_VER}.tar.gz
|
|---|
| 45 | tar xzf nginx-${NGINX_VER}.tar.gz
|
|---|
| 46 | cd /tmp/nginx-${NGINX_VER}
|
|---|
| 47 | wget -q https://raw.githubusercontent.com/cujanovic/nginx-dynamic-tls-records-patch/master/nginx__dynamic_tls_records_1.13.0%2B.patch -O dynamic_records.patch
|
|---|
| 48 | patch -p1 < dynamic_records.patch
|
|---|
| 49 | ./configure --prefix=/etc/nginx \
|
|---|
| 50 | --sbin-path=/usr/local/sbin/nginx \
|
|---|
| 51 | --http-log-path=/var/log/nginx/logs/nginx_access.log \
|
|---|
| 52 | --error-log-path=/var/log/nginx/logs/nginx_error.log \
|
|---|
| 53 | --pid-path=/run/nginx.pid \
|
|---|
| 54 | --lock-path=/run/nginx.lock \
|
|---|
| 55 | --user=nginx --group=nginx \
|
|---|
| 56 | --with-http_ssl_module \
|
|---|
| 57 | --with-http_realip_module \
|
|---|
| 58 | --with-http_addition_module \
|
|---|
| 59 | --with-http_sub_module \
|
|---|
| 60 | --with-http_dav_module \
|
|---|
| 61 | --with-http_flv_module \
|
|---|
| 62 | --with-http_mp4_module \
|
|---|
| 63 | --with-http_gunzip_module \
|
|---|
| 64 | --with-http_gzip_static_module \
|
|---|
| 65 | --with-http_random_index_module \
|
|---|
| 66 | --with-http_secure_link_module \
|
|---|
| 67 | --with-http_stub_status_module \
|
|---|
| 68 | --with-threads \
|
|---|
| 69 | --with-stream \
|
|---|
| 70 | --with-stream_ssl_module \
|
|---|
| 71 | --with-http_slice_module \
|
|---|
| 72 | --with-mail \
|
|---|
| 73 | --with-pcre-jit \
|
|---|
| 74 | --with-mail_ssl_module \
|
|---|
| 75 | --with-http_v2_module \
|
|---|
| 76 | --with-file-aio \
|
|---|
| 77 | --with-ipv6 \
|
|---|
| 78 | --add-module=/tmp/headers-more-nginx-module \
|
|---|
| 79 | --add-module=/tmp/nginx-ct \
|
|---|
| 80 | --add-module=/tmp/ngx_brotli \
|
|---|
| 81 | --with-cc-opt="-O3 -fPIE -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -Wno-deprecated-declarations" \
|
|---|
| 82 | --with-openssl-opt='no-async enable-ec_nistp_64_gcc_128 no-shared no-ssl2 no-ssl3 no-comp no-idea no-weak-ssl-ciphers -DOPENSSL_NO_HEARTBEATS -O3 -fPIE -fstack-protector-strong -D_FORTIFY_SOURCE=2' \
|
|---|
| 83 | --with-openssl=/tmp/openssl-${OPENSSL_VER}
|
|---|
| 84 | make -j 1
|
|---|
| 85 | make install
|
|---|
| 86 | useradd --no-create-home nginx
|
|---|