简体   繁体   English

Tomcat 8中的HTTP / 2支持

[英]HTTP/2 support in Tomcat 8

After some research, I was surprised that I did not not find any resource on HTTP/2 support in Tomcat. 经过一些研究,我很惊讶我没有在Tomcat中找到任何有关HTTP / 2支持的资源。 Changelogs of 8.0 indicate an experimental support of SPDY and wiki refers to HTTP/2 as a supported spec ( http://wiki.apache.org/tomcat/Specifications ) but I don't find any tutorial on it. 更改日志8.0表示SPDY的实验支持,wiki将HTTP / 2称为支持的规范( http://wiki.apache.org/tomcat/Specifications ),但我没有找到任何教程。

Do you know if it is already possible to enable HTTP/2 on Tomcat? 你知道是否已经可以在Tomcat上启用HTTP / 2了吗? If the answer is yes how I can do that? 如果答案是肯定的我怎么能这样做?

Tomcat does not yet support HTTP/2. Tomcat尚不支持HTTP / 2。

HTTP/2 support is planned for Tomcat 9 onwards. 从Tomcat 9开始计划支持HTTP / 2。 It may get back-ported to earlier versions. 它可能会被反向移植到早期版本。

The experimental SPDY support was just that: experimental. 实验性的SPDY支持就是:实验性的。 It worked while the browsers supported the particular version of SPDY but no browser currently supports the version of SDPY implemented by Tomcat. 它在浏览器支持特定版本的SPDY时起作用,但目前没有浏览器支持Tomcat实现的SDPY版本。

That experimental support of SPDY has been removed from Tomcat 8.0.22, noted in the changelog . SPDY的实验性支持已从更改日志中记录的Tomcat 8.0.22中删除。

Tomcat 8.5 has been released with features back-ported from Tomcat 9 and includes HTTP/2 support. Tomcat 8.5已发布,具有从Tomcat 9反向移植的功能,并包含HTTP / 2支持。

I haven't personally had the chance to setup HTTP/2 on Tomcat 8.5 yet, so I can't comment on the "how to". 我个人还没有机会在Tomcat 8.5上设置HTTP / 2,所以我无法评论“如何”。

HTTP/2 Support is now available in Tomcat . 现在可以在Tomcat中使用HTTP / 2支持 Tomcat-8.5 supports HTTP/2. Tomcat-8.5支持HTTP / 2。 To enable HTTP/2 in tomcat-8.5 or above you need to upgrade the connector protocol in the file server.xml in the tomcat conf folder. 要在tomcat-8.5或更高版本中启用HTTP / 2,您需要升级tomcat conf文件夹中文件server.xml中的连接器协议。

<Connector ... >
  <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
</Connector>

You also need to set up the configuration of your SSL certificates to work with this connector. 您还需要设置SSL证书的配置以使用此连接器。

to enable http2 for tomcat8.5.x, 为tomcat8.5.x启用http2,

@Bean
       public EmbeddedServletContainerCustomizer tomcatCustomizer() {
        return container -> {
            if (container instanceof TomcatEmbeddedServletContainerFactory) {
                ((TomcatEmbeddedServletContainerFactory) container).addConnectorCustomizers((connector) -> {
                    connector.addUpgradeProtocol(new Http2Protocol());
                });
            }
        };
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM