nginx1.9.3 HTTP/2 パッチを試す

1.9.5でHTTP2がサポートされました。Nginx 1.9.5 でHTTP2を試そう!(2015/0923)


nginx 1.9.3のHTTP/2アルファパッチが公開されました。
https://www.nginx.com/blog/early-alpha-patch-http2/


基本的には書いてあるとおりにヤレば簡単に動作します。
ubuntu14.04で試したがすんなり起動できた

必要な物を入れる

いつもの

sudo apt-get install build-essential libc6 libpcre3 libpcre3-dev libpcrecpp0 libssl0.9.8 libssl-dev zlib1g zlib1g-dev lsb-base

ダウンロード

# nginx本体
wget http://nginx.org/download/nginx-1.9.3.tar.gz
tar zxvf nginx-1.9.3.tar.gz


#パッチ
cd ./nginx-1.9.3
wget http://nginx.org/patches/http2/patch.http2-v2_1.9.3.txt
patch -p1 --dry-run < patch.http2.txt
patch -p1 < patch.http2.txt
cd ../

# openssl
wget https://www.openssl.org/source/openssl-1.0.2d.tar.gz
tar zxvf ./openssl-1.0.2d.tar.gz

ビルド

cd ./nginx-1.9.3
./configure --with-http_ssl_module \
            --with-http_v2_module \
            --with-debug \
            --with-openssl=/path/to/openssl-1.0.2 
make

conf

/usr/local/nginx/conf/nginx.conf
証明書などは良しなに

worker_processes 1;

events {
    worker_connections 1024;
}

http {
    include     mime.types;
    default_type application/octet-stream;

    sendfile        on;

    keepalive_timeout 65;
    client_max_body_size 20M;

    server {
        listen  443 ssl http2 ;
        server_name localhost;
        ssl_certificate     /home/vagrant/server.crt;
        ssl_certificate_key /home/vagrant/server.key;

        location / {
          root /usr/share/www;
        }
    }
}

起動

sudo ./nginx-1.9.3/objs/nginx

確認

chromeからアクセスし、「chrome://net-internals/#http2」より

t=2230 [st=  0]  HTTP2_SESSION_SEND_HEADERS
                 --> fin = true
                 --> :authority: localhost
                     :method: GET
                     :path: /
                     :scheme: https
                     accept-encoding: gzip, deflate, sdch
                     (略)
                 --> priority = 0
                 --> stream_id = 3
                 --> unidirectional = false
t=2237 [st=  7]  HTTP2_SESSION_RECV_HEADERS
                 --> fin = false
                 --> :status: 200
                     accept-ranges: bytes
                     content-length: 5
                     content-type: text/html
                     date: Thu, 06 Aug 2015 13:47:26 GMT
                     etag: "55c36093-5"
                     last-modified: Thu, 06 Aug 2015 13:26:43 GMT
                     server: nginx/1.9.3
                 --> stream_id = 3

良さそう