编译安装nghttp2遇到的问题

本文只是记录编译nghttp2所遇到的问题的解决方法,具体步骤请看这里(十分详细)。


环璄:Ubuntu 14.04TLS X64
1、nghttp2依赖spdylay,安装spdylay后,运行spdycat提示:

spdycat: error while loading shared libraries: libspdylay.so.7: cannot open shared object file: No such file or directory

然后ldd `which spdycat`,会发现缺少运行库libspdylay.so.7

ldd `which spdycat`
	linux-vdso.so.1 =>  (0x00007fffced6e000)
	libssl.so.1.0.0 => /lib/x86_64-linux-gnu/libssl.so.1.0.0 (0x00007ff963dff000)
	libcrypto.so.1.0.0 => /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 (0x00007ff963a24000)
	libxml2.so.2 => /usr/lib/x86_64-linux-gnu/libxml2.so.2 (0x00007ff9636bd000)
	libspdylay.so.7 => not found
	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007ff9633b9000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007ff9631a2000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ff962f84000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff962bbf000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ff9629ba000)
	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007ff9627a1000)
	liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007ff96257f000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ff962278000)
	/lib64/ld-linux-x86-64.so.2 (0x00007ff964066000)

运行find /usr/local -name libspdylay.so

/usr/local/lib/libspdylay.so

创建libspdylay.so的软链接,再次运行spdycat,无错误返回即可

sudo ln -s /usr/local/lib/libspdylay.so /lib/x86_64-linux-gnu/libspdylay.so.7

2、nghttp2同样会遇到缺运行库的错误,同样地ln -s

sudo ln -s /usr/local/lib/libnghttp2.so /lib/x86_64-linux-gnu/libnghttp2.so.5
nghttpx
Usage: nghttpx [OPTIONS]... [<PRIVATE_KEY> <CERT>]
A reverse proxy for HTTP/2, HTTP/1 and SPDY.
01/Apr/2015:00:20:13 +0800 PID14428 [FATAL] shrpx.cc:1999 Too few arguments

至此,编译、安装部分完成。

3、Chrome连接nghttp2 proxy时报spdy错误
“Error code:ERR_SPDY_PROTOCOL_ERROR”,这是Chrome的BUG,只需要把nghttpx协商的优先顺序改为spdy/3.1即可

sudo nghttpx -s -f0.0.0.0,443 -b127.0.0.1,8080 \
/etc/nghttpx/certs/ssl.key /etc/nghttpx/certs/ssl.crt \
--npn-list=spdy/3.1,h2

编译安装nghttp2遇到的问题》有2个想法

  1. 3、Chrome连接nghttp2 proxy时报spdy错误
    “Error code:ERR_SPDY_PROTOCOL_ERROR”,这是Chrome的BUG,只需要把nghttpx运行在spdy/3.1下即可

    核对一下你OpenSSL什么版本,Git上有提到,最低要求是OpenSSL >= 1.0.1

    但是必须OpenSSL >= 1.0.2才支持ALPN

    ALPN是HTTP/2必须的

发表评论

电子邮件地址不会被公开。 必填项已用*标注