ALPN on Debian GNU/Linux 8 (jessie)

Please note that you will be installing OpenSSL 1.0.2 from backports. Debian backports are not maintained by the Debian Security Team and you might be introducing vulnerabilities to your system. Upgrade to Debian GNU/Linux 9 (stretch) if you can, instead.

Additionally, if you're using Debian-specific modules like Lua, you will no longer have them after upgrading to the mainline repository of nginx.org.

If you still wish to continue, do the following:

cp -pR /etc/nginx /etc/nginx.bak
dpkg -l nginx | grep ^ii | awk '{ print $2 }' | xargs dpkg --purge
echo 'deb http://deb.debian.org/debian jessie-backports main' > /etc/apt/sources.list.d/backports.list
apt-key adv --fetch http://nginx.org/keys/nginx_signing.key
echo 'deb http://nginx.org/packages/mainline/ubuntu/ xenial nginx' > /etc/apt/sources.list.d/nginx.list
apt -qq update
apt install -yt jessie-backports openssl
apt-get install nginx
openssl req     -newkey rsa:2048 -nodes -keyout /etc/nginx/key.pem \
        -x509   -days 365   -out    /etc/nginx/certificate.pem
cat << EOF > conf.d/ssl.conf
server {
        listen 443 ssl http2 reuseport;
        server_name localhost;

        ssl_certificate certificate.pem;
        ssl_certificate_key key.pem;

        return 200 "No website configured at this address.";
}
EOF
nginx -t
nginx
echo |  openssl s_client -alpn h2 -connect localhost:443 2>&1 | \
    grep -q '^ALPN protocol: ' \
&&  echo "ALPN detected." \
||  echo "No ALPN support detected."