Debian jessie nginx 搭配 openssl 1.0.2 使用 ALPN 而非 NPN

Debian jessie nginx 搭配 openssl 1.0.2 使用 ALPN 而非 NPN

我的服务器上运行的是 debian jessie,最近升级到了支持 http/2 的新 nginx web 服务器 (nginx 1.10)。截至目前,它运行良好,web 服务器正在使用 http2 协议传递内容。

我读过chrome 正在放弃 NPN 支持并且仅在 2016 年 5 月 15 日之后允许使用 ALPN。ALPN 是扩展,需要安装 openssl 1.0.2,但在 debian jessie 上只有 openssl 1.0.1(此外,在 debian backports 和其他存储库中,此 debian 没有 openssl 1.0.2 版本)。

还有一个问题 - 我已经从 SPDY 升级到 http2,几天后,我将不得不关闭 http2 并且无法使用 SPDY,因为此版本的 nignx 只有 http2。我还读到,此版本的 debian 将坚持使用 openssl 1.0.1,只有 debian stretch 才会有 openssl 1.0.2。但距离发布日期还有将近一年的时间,chrome 很快就会放弃支持,所以我不想失去 http2 协议的好处。

有什么解决方案吗?如何在该系统上安装 openssl 1.0.2,而无需自行构建版本(维护不善)或等待 backports 存储库拥有它?如果其中一个版本必须手动链接和维护,我也不希望我的系统上有两个版本的 openssl。

谢谢你的帮助。

答案1

更新2016/08/08: nginxjessie-backports(版本1.9.10-1~bpo8+3是针对 构建的openssl >= 1.0.2~ALPN现在运行jessie只需要将包从 中取出jessie-backports,无需再将包从 中拉出stretch

--

原始答案:好吧,根据评论,我的答案如下:在我看来,截至今天(2016/05/09),解决这个问题的方法并不多。基本上你必须尝试不知何故将现代化的东西nginx融入到你的系统中,并针对 进行编译>= openssl 1.0.2~

目前我看到的只有两个选择:要么你自己编译,但你不想这样做,这很容易理解,要么你将现代软件包拉入Debian stretch你的系统。这涉及一些风险,因为你将一个稳定的环境与另一个环境混合在一起,但在我看来这些风险相当低,因为你正在使用Debian

那么,让我们尝试一下:

  • 将存储库添加Debian stretch到您的apt sources。不要/etc/apt/sources.list为此使用,而是使用里面的专用文件/etc/apt/sources.list.d/来保持清洁,我个人使用stretch.list

    把以下几行放在里面:

    deb http://httpredir.debian.org/debian/ stretch main contrib non-free
    deb-src http://httpredir.debian.org/debian/ stretch main contrib non-free
    
    deb http://security.debian.org/ stretch/updates main contrib non-free
    deb-src http://security.debian.org/ stretch/updates main contrib non-free
    
    # stretch-updates, previously known as 'volatile'
    deb http://httpredir.debian.org/debian/ stretch-updates main contrib non-free
    deb-src http://httpredir.debian.org/debian/ stretch-updates main contrib non-free
    
  • 设置贴合确保只提取Debian stretch您指定的包。要使用的文件是/etc/apt/preferences,在其中放入:

    Package: *
    Pin: release n=jessie
    Pin-Priority: 900
    
    Package: * 
    Pin: release a=jessie-backports
    Pin-Priority: 500
    
    Package: *
    Pin: release n=stretch
    Pin-Priority: 100
    

    (您可能需要改变套件和优先级以适合您的环境。)

  • 运行apt-get update(via sudo/ as root)来更新包缓存。

  • 安装nginxDebian stretch:(apt-get install -t stretch nginx通过sudo/ 作为执行此操作root)。获利!

  • 正如我在评论中所描述的那样,为了进一步降低所涉及的风险,您可以使用类似chroot或者类似容器解决方案龙芯。如果你想走这chroot条路,你必须在那里设置一个网络接口:要做到这一点,看看例如在这篇博文中,介绍了network namespaces

  • 希望这能有所帮助;如果您还有其他问题,请随时联系我。我很感激您的反馈,我对进展很感兴趣。

答案2

另一种方法是从 jessie-backports 安装 OpenSSL 1.0.2,并使用来自nginx 自己的存储库。这样,您至少可以使用为 Jessie 构建的 OpenSSL 包。

添加/etc/apt/sources.list

# jessie-backports, from stretch-level but with no dependencies
deb http://httpredir.debian.org/debian/ jessie-backports main contrib non-free
deb-src http://httpredir.debian.org/debian/ jessie-backports main contrib non-free

# Nginx repository - use Ubuntu 16.04 LTS Xenial to get packages compiled with OpenSSL 1.0.2
deb http://nginx.org/packages/mainline/ubuntu/ xenial nginx
deb-src http://nginx.org/packages/mainline/ubuntu/ xenial nginx

然后运行:

apt-get update
apt-get install -t jessie-backports openssl
apt-get install nginx

这显然让你陷入正式不支持的配置,但这可能比根本没有包要好 - 而且对我来说它有效。此外,使用 nginx 的 repo 意味着您可以获得最新的更新。

答案3

另一种方法是使用 jessie-backports,然后轻松重建 nginx

添加到 /etc/apt/sources.list backports

deb http://ftp.debian.org/debian jessie-backports main

然后以 root 身份运行

apt-get update
apt-get install -t jessie-backports openssl

然后重建 nginx。按照说明进行操作https://wiki.debian.org/BuildingAPackage

答案4

另一种方法是使用 BoringSSL,这不会损害 OpenSSL 环境。以下是详细信息,供参考:https://www.admon.org/hardwares/enable-http2-support-for-nginx-on-debian-jessie

相关内容