El Lord Code El Lord Code - 1 year ago 281
Java Question

Enable HTTP 2.0 for Undertow in Spring Boot

I wonder how I can enable the HTTP 2.0 for Undertow using Spring Boot, I monitored the protocol and currently HTTPS is using 1.1.

Is there any property for it? Or should I create a EmbeddedServletContainerFactory with this option.


Answer Source

You need to add the following bean to the configuration

    UndertowEmbeddedServletContainerFactory embeddedServletContainerFactory() {
        UndertowEmbeddedServletContainerFactory factory = new UndertowEmbeddedServletContainerFactory();
                builder -> builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true));
        return factory;

Then start the application with alpn-boot-8.1.9.v20160720.jar in the boot class path

java -Xbootclasspath/p:<<location>>/alpn-boot-8.1.9.v20160720.jar -jar <<your application>>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download