如何在http2支持的CentOS 7上构buildApache httpd 2.4.20?

我花了将近一天的时间,尝试着为我的公司和社会制作ALPN和http2支持EL6和EL7的Apache httpd版本,正如我之前对NGINX (静态构build的OpenSSL 1.0.2h)所做的那样。

首先,我试着用从Fedora取得的OpenSSL 1.0.2h重buildsrc rpms并安装结果rpms(openssl-devel-1.0.2h-1.el7.centos.x86_64.rpm,openssl-1.0.2h-1.el7.centos .x86_64.rpm)replace系统的一个。 是的,我知道,这对于公共build筑来说是不正确的,但是我需要知道是否可以工作。

然后我重build了nghttp2-1.7.1-1.fc24.src.rpm并安装了libnghttp2-devel-1.7.1-1.el7.centos.x86_64.rpm和libnghttp2-1.7.1-1.el7.centos .x86_64.rpm。

最后,在删除了一些修补程序并且攻击了apr和apr-util后,我成功地将httpd-2.4.18-1.fc23.src.rpm生成到httpd-2.4.18-1.el7.centos.x86_64.rpm中。

纯HTTP / 1.1为我工作好,ALPN支持也存在,但HTTP / 2没有工作:

$ curl -v --insecure --http2 --tlsv1.2 https://192.168.1.148 * Rebuilt URL to: https://192.168.1.148/ * Trying 192.168.1.148... * Connected to 192.168.1.148 (192.168.1.148) port 443 (#0) * Initializing NSS with certpath: sql:/etc/pki/nssdb * skipping SSL peer certificate verification * ALPN, server accepted to use h2 * SSL connection using TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA * Server certificate: * subject: [email protected],CN=centos7.dcodeit.net,OU=SomeOrganizationalUnit,O=SomeOrganization,L=SomeCity,ST=SomeState,C=-- * start date: май 25 13:11:19 2016 GMT * expire date: май 25 13:11:19 2017 GMT * common name: centos7.dcodeit.net * issuer: [email protected],CN=centos7.dcodeit.net,OU=SomeOrganizationalUnit,O=SomeOrganization,L=SomeCity,ST=SomeState,C=-- * Using HTTP2, server supports multi-use * Connection state changed (HTTP/2 confirmed) * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 * Using Stream ID: 1 (easy handle 0x55ccf55b44c0) > GET / HTTP/1.1 > Host: 192.168.1.148 > User-Agent: curl/7.43.0 > Accept: */* > * http2_recv: 16384 bytes buffer at 0x55ccf55b4e08 (stream 1) * http2_recv: 16384 bytes buffer at 0x55ccf55b4e08 (stream 1) * Unexpected EOF * Closing connection 0 curl: (56) Unexpected EOF 

我认为Fedora的一些补丁可能会出现问题,并且试图重build其他部分而没有任何运气。 最后,我删除了所有的“devel”rpms,下载了最新的stable httpd-2.4.20,把apr和apr-util未经修改的最新源码放到它的srclib目录下,试着用:

 CFLAGS="-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic"; export CFLAGS LDFLAGS="-Wl,-z,relro,-z,now"; export LDFLAGS "./configure" \ "--prefix=/etc/httpd" \ "--exec-prefix=/usr" \ "--bindir=/usr/bin" \ "--sbindir=/usr/sbin" \ "--mandir=/usr/share/man" \ "--libdir=/usr/lib64" \ "--sysconfdir=/etc/httpd/conf" \ "--includedir=/usr/include/httpd" \ "--libexecdir=/usr/lib64/httpd/modules" \ "--datadir=/usr/share/httpd" \ "--enable-layout=Fedora" \ "--with-installbuilddir=/usr/lib64/httpd/build" \ "--enable-mpms-shared=all" \ "--enable-suexec" \ "--with-included-apr" \ "--with-suexec" \ "--enable-suexec-capabilities" \ "--with-suexec-caller=apache" \ "--with-suexec-docroot=/var/www" \ "--without-suexec-logfile" \ "--with-suexec-syslog" \ "--with-suexec-bin=/usr/sbin/suexec" \ "--with-suexec-uidmin=1000" \ "--with-suexec-gidmin=1000" \ "--enable-pie" \ "--with-pcre" \ "--enable-mods-shared=all" \ "--enable-ssl" \ "--with-ssl=/root/openssl-1.0.2h" \ "--enable-ssl-staticlib-deps" \ "--with-nghttp2=/root/nghttp2-1.11.0" \ "--enable-nghttp2-staticlib-deps" \ "LDFLAGS=-Wl,-z,relro,-z,now" \ "CFLAGS=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic" 

正如你所看到的,我试图用最新的库版本静态地构buildmod_ssl和mod_http2,但http2仍然不能用完全相同的错误消息:服务器在没有任何答复的情况下删除连接。 在日志中没有数据可以find:根本没有在日志中显示请求,而http / 1.1,http / 1.1 over SSL和h2c请求被正确logging和处理。

我的configuration文件现在几乎是一个(从未修改的httpd-2.4.20),但启用了mod_ssl,mod_http2和“协议h2 http / 1.1”。

更奇怪的是:我试图添加“LogLevel http2:info”来debugginghttp2,但我无法看到像“[http2:info] [pid XXXXX:tid numbers] mod_http2(v1.0.0,nghttp2 1.3.4),初始化…“。 但是,我相信http2模块是打开的,因为这个日志级别没有configuration错误。 另外我用h2c(http2 over plain http)检查它,它完美的工作与curl和“101切换协议”的答复。

所以,我试图用不同的lib版本dynamic地构build它,最后我没有任何运气使用干净的,未经修改的nghttp2,openssl,apr,apr-util,configuration文件的源代码,但是HTTP / 2和ALPN分别正常工作。

请指教。

我注意到你正在使用这个密码套件:TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA

但是,该密码是黑名单中列出的HTTP / 2: https : //tools.ietf.org/html/rfc7540

默认情况下,mod_http2不允许你与黑名单密码协商: https ://httpd.apache.org/docs/2.4/mod/mod_http2.html#h2moderntlsonly

所以我想知道这是唯一的问题,你只需要启用更现代的密码套件? 特别是ECDHE与GCM而不是CBC套件,如TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA25。 您可以随时在卷标上closures标志,但Chrome同样使用这个黑名单,因此无论如何您都需要启用其他密码(您为什么不想要这样做,因为您已经为此升级了openssl的麻烦)。

如果这不是问题,那么你可以看看我在这里给出的一步一步的指示,如何从源代码构build: https : //www.tunetheweb.com/performance/http2/ 。 我使用Centos 7,这些步骤适用于我。