You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Prior to this commit, the how-to documentation would say that Spring
Boot does not support the h2c protocol. While it's not supported
out-of-the-box with a configuration property, this protocol can still be
configured using server customizers.
This commit documents, with code snippets, the server customizers one
should use to configure the h2c protocol in an application - for each
supported server.
Closesgh-21997
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc
+75-16Lines changed: 75 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -582,25 +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
-
As of Jetty 9.4.8, HTTP/2 is also supported with the https://www.conscrypt.org/[Conscrypt library].
600
-
To enable that support, your application needs to have two additional dependencies: `org.eclipse.jetty:jetty-alpn-conscrypt-server` and `org.eclipse.jetty.http2:http2-server`.
601
-
602
-
603
-
604
591
[[howto-configure-http2-tomcat]]
605
592
==== HTTP/2 with Tomcat
606
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.
@@ -621,6 +608,13 @@ This error is not fatal, and the application still starts with HTTP/1.1 SSL supp
621
608
622
609
623
610
611
+
[[howto-configure-http2-jetty]]
612
+
==== HTTP/2 with Jetty
613
+
As of Jetty 9.4.8, HTTP/2 is also supported with the https://www.conscrypt.org/[Conscrypt library].
614
+
To enable that support, your application needs to have two additional dependencies: `org.eclipse.jetty:jetty-alpn-conscrypt-server` and `org.eclipse.jetty.http2:http2-server`.
615
+
616
+
617
+
624
618
[[howto-configure-http2-netty]]
625
619
==== HTTP/2 with Reactor Netty
626
620
The `spring-boot-webflux-starter` is using by default Reactor Netty as a server.
@@ -633,6 +627,71 @@ Developers can choose to import only the required dependencies using a classifie
633
627
634
628
635
629
630
+
[[howto-configure-http2-undertow]]
631
+
==== HTTP/2 with Undertow
632
+
As of Undertow 1.4.0+, HTTP/2 is supported without any additional requirement on JDK8.
633
+
634
+
635
+
636
+
[[howto-configure-http2-h2c]]
637
+
==== h2c with supported servers
638
+
To enable `h2c`, you need to leave the configprop:server.http2.enabled[] property set to `false`,
639
+
and instead apply a customizer specific to your choice of server:
public UndertowBuilderCustomizer builderCustomizer() {
686
+
return (builder) -> {
687
+
builder.setServerOption(ENABLE_HTTP2, true);
688
+
};
689
+
}
690
+
----
691
+
692
+
693
+
694
+
636
695
[[howto-configure-webserver]]
637
696
=== Configure the Web Server
638
697
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