DirectAdmin 启用HTTP/2支持

Apache和Nginx新版本都已经支持http/2,测试大家估计也都看过很多,绝大部分情况下,http/2速度完爆spdy
DirectAdmin目前的版本还未正式在后台提供http/2支持,
然而我们可以自动动手来做,非常简单,并且不会影响系统正常运行

首先安装新版的OpenSSL,因为只有新版的才支持ALPN
我这里直接安装到其他位置不会覆盖系统原有的openssl

wget http://codes.yutian.org/Linux/software/openssl-1.0.2d.tar.gz
tar xzf openssl-1.0.2d.tar.gz
cd openssl-1.0.2d
./config --prefix=/usr/local/lib_http2 no-ssl2 no-ssl3 zlib-dynamic
make depend
make install

然后安装nghttp2,DirectAdmin面板已经自带,
然而并未正式提供该功能,应该是为了以后支持http/2提前做好了准备

cd /usr/local/directadmin/custombuild
./build update
./build nghttp2

拷贝文件,启用自定义Apache编译规则

cd /usr/local/directadmin/custombuild
mkdir -p custom/ap2
cp -p configure/ap2/configure.apache custom/ap2/configure.apache

修改 /usr/local/directadmin/custombuild/custom/ap2/configure.apache文件
找到这一行

    "--with-ssl=/usr" \

修改为这样

    "--enable-http2" \
    "--enable-ssl-staticlib-deps" \
    "--with-ssl=/usr/local/lib_http2" \

开始编译Apache

./build apache

编辑httpd文件加入http/2支持语句

echo 'ProtocolsHonorOrder On' >> /etc/httpd/conf/extra/httpd-includes.conf
echo 'Protocols h2 h2c http/1.1' >> /etc/httpd/conf/extra/httpd-includes.conf

更新SSL Ciphers /etc/httpd/conf/extra/httpd-ssl.conf

cd /usr/local/directadmin/custombuild
./build rewrite_confs

然后就可以了。目前测试http/2的支持还算完美,然而有一个不大不小的bug 存在,
我自己测试发现如果使用泛域名证书的话,浏览器只能成功访问第一个引用的https网站,第二个会失败
比如:*.xxx.com泛域名证书,你在同一个服务器上部署了多个二级域名,a.xxx.com和b.xxx.com,
你访问了https://a.xxx.com后,再访问https://b.xxx.com就会失败,这个是Apache新版本的bug,下个版本才会修复

原文链接:https://yusky.me/directadmin-enabled-http2-support.html,转载请注明出处。
0

评论2

  1. 现在网站又不支持http/2了?
    loren 2016-03-04 0 回复
    • 好啦。现在打开了。
      Yusky 2016-03-04 0 回复
没有账号?注册  忘记密码?