Tomcat 9.x supports HTTP2 that offers better website performance and speed. It results in faster application load times and overall improvement. In this article, we will look at how to enable HTTP2 in Tomcat.
How to Enable HTTP2 in Tomcat
Here are the steps to enable HTTP2 in Tomcat web server. Please note, you need a Tomcat server installed & configured with SSL/TLS certificate before enabling HTTP2.
1. Open server.xml file
Go to Tomcat installation folder. Go to conf sub folder. Open server.xml file using a text editor.
$ sudo vi conf/server.xml
Also read : How to Install PgAdmin 4 in Ubuntu
2. Enable HTTP2 in Tomcat
Add the following lines to your server configuration. Please update the file path of .pem files in case they are not present in conf folder. Similarly, update port number from 443 to whatever you use for SSL/TLS
<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>
Also read : How to Serve Static Files in NodeJS
3. Restart Tomcat Server
Go to bin subfolder in Tomcat installation location and run the following scripts.
That’s it. Now HTTP2 will be enabled in your Tomcat Server. You can easily check if your website is working on HTTP2 using third party internet tools like HTTP2.Pro
Also read : How to Configure X-Frame-Options for NGINX