How to Enable HTTP2 in Tomcat

How to Enable HTTP2 in Tomcat

HTTP/2 connectors use non-blocking I/O, only utilizing a container thread from the thread pool when there is data to read and write.

For more information read The HTTP2 upgrade protocol – Apache Tomcat 8 Configuration Reference.

There are two steps in enabling HTTP2 in Tomcat:

  1. Edit the server.xml file
  2. Restart Tomcat server

1. Open the server.xml file:

nano conf/server.xml

Add the following to the configuration:

<Connector port="443" protocol="org.apache.coyote.http11.Http11AprProtocol"
               maxThreads="150" SSLEnabled="true" >
        <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
        <SSLHostConfig>
            <Certificate certificateKeyFile="conf/key.pem"
                         certificateFile="conf/cert.pem"
                         certificateChainFile="conf/chain.pem"
                         type="RSA" />
        </SSLHostConfig>
    </Connector>

If you are using a custom port for SSL/TLS make sure to change 443 port, and if your certificate files are not in the conf folder, make sure to update the file path of .pem files.

2. Save the changes and restart Tomcat server:

./shutdown.sh
./startup.sh
whoami
Stefan Pejcic
Join the discussion

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.