@@ -582,29 +582,12 @@ This support depends on the chosen web server and the application environment, s
582
582
583
583
[NOTE]
584
584
====
585
- Spring Boot does not support `h2c`, the cleartext version of the HTTP/2 protocol.
586
- So you must <<howto-configure-ssl, configure SSL first>>.
585
+ Spring Boot does not advise using `h2c`, the cleartext version of the HTTP/2 protocol.
586
+ As a result, the next sections require to <<howto-configure-ssl, configure SSL first>>.
587
+ If you still choose to use `h2c`, you can check <<howto-configure-http2-h2c, the dedicated section>>.
587
588
====
588
589
589
590
590
-
591
- [[howto-configure-http2-undertow]]
592
- ==== HTTP/2 with Undertow
593
- As of Undertow 1.4.0+, HTTP/2 is supported without any additional requirement on JDK8.
594
-
595
-
596
-
597
- [[howto-configure-http2-jetty]]
598
- ==== HTTP/2 with Jetty
599
- For HTTP/2 support, Jetty requires the additional `org.eclipse.jetty.http2:http2-server` dependency.
600
- Now depending on your deployment, you also need to choose other dependencies:
601
-
602
- * `org.eclipse.jetty:jetty-alpn-java-server` for applications running on JDK9+
603
- * `org.eclipse.jetty:jetty-alpn-openjdk8-server` for applications running on JDK8u252+
604
- * `org.eclipse.jetty:jetty-alpn-conscrypt-server` and the https://www.conscrypt.org/[Conscrypt library] with no JDK requirement
605
-
606
-
607
-
608
591
[[howto-configure-http2-tomcat]]
609
592
==== HTTP/2 with Tomcat
610
593
Spring Boot ships by default with Tomcat 9.0.x which supports HTTP/2 out of the box when using JDK 9 or later.
@@ -624,6 +607,16 @@ Starting Tomcat 9.0.x on JDK 8 without that native support logs the following er
624
607
This error is not fatal, and the application still starts with HTTP/1.1 SSL support.
625
608
626
609
610
+ [[howto-configure-http2-jetty]]
611
+ ==== HTTP/2 with Jetty
612
+ For HTTP/2 support, Jetty requires the additional `org.eclipse.jetty.http2:http2-server` dependency.
613
+ Now depending on your deployment, you also need to choose other dependencies:
614
+
615
+ * `org.eclipse.jetty:jetty-alpn-java-server` for applications running on JDK9+
616
+ * `org.eclipse.jetty:jetty-alpn-openjdk8-server` for applications running on JDK8u252+
617
+ * `org.eclipse.jetty:jetty-alpn-conscrypt-server` and the https://www.conscrypt.org/[Conscrypt library] with no JDK requirement
618
+
619
+
627
620
628
621
[[howto-configure-http2-netty]]
629
622
==== HTTP/2 with Reactor Netty
@@ -637,6 +630,71 @@ Developers can choose to import only the required dependencies using a classifie
637
630
638
631
639
632
633
+ [[howto-configure-http2-undertow]]
634
+ ==== HTTP/2 with Undertow
635
+ As of Undertow 1.4.0+, HTTP/2 is supported without any additional requirement on JDK8.
636
+
637
+
638
+
639
+ [[howto-configure-http2-h2c]]
640
+ ==== h2c with supported servers
641
+ To enable `h2c`, you need to leave the configprop:server.http2.enabled[] property set to `false`,
642
+ and instead apply a customizer specific to your choice of server:
643
+
644
+ For Tomcat, we need to add an upgrade protocol:
645
+
646
+ [source,java,indent=0,subs="verbatim,quotes,attributes"]
647
+ ----
648
+ @Bean
649
+ public TomcatConnectorCustomizer connectorCustomizer() {
650
+ return (connector) -> connector.addUpgradeProtocol(new Http2Protocol());
651
+ }
652
+ ----
653
+
654
+ For Jetty, we need to add a connection factory to the existing connector:
655
+
656
+ [source,java,indent=0,subs="verbatim,quotes,attributes"]
657
+ ----
658
+ @Bean
659
+ public JettyServerCustomizer serverCustomizer() {
660
+ return (server) -> {
661
+ HttpConfiguration configuration = new HttpConfiguration();
662
+ configuration.setSendServerVersion(false);
663
+ Arrays.stream(server.getConnectors())
664
+ .filter(connector -> connector instanceof ServerConnector)
665
+ .map(ServerConnector.class::cast)
666
+ .forEach(connector -> {
667
+ connector.addConnectionFactory(new HTTP2CServerConnectionFactory(configuration));
668
+ });
669
+ };
670
+ }
671
+ ----
672
+
673
+ For Netty, we need to add `h2c` as a supported protocol:
674
+
675
+ [source,java,indent=0,subs="verbatim,quotes,attributes"]
676
+ ----
677
+ @Bean
678
+ public NettyServerCustomizer serverCustomizer() {
679
+ return (server) -> server.protocol(HttpProtocol.H2C);
680
+ }
681
+ ----
682
+
683
+ For Undertow, we need to enable the HTTP2 option:
684
+
685
+ [source,java,indent=0,subs="verbatim,quotes,attributes"]
686
+ ----
687
+ @Bean
688
+ public UndertowBuilderCustomizer builderCustomizer() {
689
+ return (builder) -> {
690
+ builder.setServerOption(ENABLE_HTTP2, true);
691
+ };
692
+ }
693
+ ----
694
+
695
+
696
+
697
+
640
698
[[howto-configure-webserver]]
641
699
=== Configure the Web Server
642
700
Generally, you should first consider using one of the many available configuration keys and customize your web server by adding new entries in your `application.properties` (or `application.yml`, or environment, etc. see "`<<howto-discover-build-in-options-for-external-properties>>`").
0 commit comments