Skip to content

Instantly share code, notes, and snippets.

@dfang
Last active October 10, 2020 18:27
Show Gist options
  • Select an option

  • Save dfang/f71d414b461b6ff77d7d070c16c9930a to your computer and use it in GitHub Desktop.

Select an option

Save dfang/f71d414b461b6ff77d7d070c16c9930a to your computer and use it in GitHub Desktop.
build nginx with ngx_pagespeed and http2 support on ubuntu 14.04

Test your web server for HTTP/2 and ALPN support KeyCDN

Test SSL strength of your setup SSL LABS

install openssl with ALPN support

chrome 51 dropped HTTP/2 via NPN
we need to support HTTP/2 via ALPN, however... on Ubuntu 14.04
NGINX has been compiled with OpenSSL 1.0.1 which does not support ALPN
so upgrade OpenSSL to 1.0.2

sudo - su
wget https://www.openssl.org/source/openssl-1.0.2-latest.tar.gz
tar xzvf openssl-1.0.2-latest.tar.gz

cd {{ dir }}
./config
make
make test
make install
openssl version

# if old version persists
mv /usr/bin/openssl /root/
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl

# move new source to /usr/lcoal for nginx conf
cd 
mv {{ dir }} /usr/local

download ngx_pagespeed

#[check the release notes for the latest version]
NPS_VERSION=1.12.34.2-stable
cd
wget https://github.com/pagespeed/ngx_pagespeed/archive/v${NPS_VERSION}.zip
unzip v${NPS_VERSION}.zip
cd ngx_pagespeed-${NPS_VERSION}/
NPS_RELEASE_NUMBER=${NPS_VERSION/beta/}
NPS_RELEASE_NUMBER=${NPS_VERSION/stable/}
psol_url=https://dl.google.com/dl/page-speed/psol/${NPS_RELEASE_NUMBER}.tar.gz
[ -e scripts/format_binary_url.sh ] && psol_url=$(scripts/format_binary_url.sh PSOL_BINARY_URL)
wget ${psol_url}
tar -xzvf $(basename ${psol_url})  # extracts to psol/

compile nginx

NGINX_VERSION=[check nginx's site for the latest version]
cd
wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
tar -xvzf nginx-${NGINX_VERSION}.tar.gz
cd nginx-${NGINX_VERSION}/
# ./configure --add-module=$HOME/ngx_pagespeed-${NPS_VERSION} ${PS_NGX_EXTRA_FLAGS}
./configure \
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--modules-path=/usr/lib/nginx/modules \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--user=nginx \
--group=nginx \
--with-compat \
--with-threads \
--with-http_addition_module \
--with-http_random_index_module \
--with-http_realip_module \
--with-http_secure_link_module \
--with-http_slice_module \
--with-http_v2_module \
--with-http_ssl_module \
--with-openssl=/usr/local/openssl-1.0.2l \
--with-http_gzip_static_module \
--add-dynamic-module=$HOME/ngx_pagespeed 
make
sudo make install

commands:

echo | openssl s_client -alpn h2 -connect example.com:443 | grep ALPN
openssl version -a
nginx -V

links:

@dfang

dfang commented Sep 5, 2017

Copy link
Copy Markdown
Author

@dfang

dfang commented Sep 5, 2017

Copy link
Copy Markdown
Author

@dfang

dfang commented Sep 5, 2017

Copy link
Copy Markdown
Author

@dfang

dfang commented Sep 7, 2017

Copy link
Copy Markdown
Author

@dfang

dfang commented Sep 7, 2017

Copy link
Copy Markdown
Author

@dfang

dfang commented Sep 7, 2017

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment