With Tomcat 8.5.31, I cant enable gzip compression with HTTP2 protocol. If
someone has successfully enabled compression on Tomcat 8.5 with HTTP2
protocol, please help me with correct configuration.

Things tried:
- tried with and without useSendfile="false" attribute under
UpgradeProtocol.
- turned off "useSendfile" by adding "sendfileSize=-1" init-param for
default servlet under conf/web.xml
- tried APR (with OpenSSL) connector too instead of NIO
- compression is not working with Chrome and Firefox (latest ver.)
- testing with default ROOT webapp to avoid any other conflicting setting
- gzip compression works with same setting on Tomcat 9.0.5
- using openjdk 10.0.1 (and tried with Oracle Java 1.8.0_144)

Using the following connector:
<Connector

protocol="org.apache.coyote.http11.Http11NioProtocol"

port="8443"

URIEncoding="UTF-8"

maxPostSize="40960000"

maxHttpHeaderSize="1024000"

maxThreads="2500"

enableLookups="false"

SSLEnabled="true"

scheme="https"

secure="true"

compression="on"

noCompressionUserAgents="gozilla,traviata"

compressableMimeType=
"text/html,text/json,application/json,text/xml,text/plain,application/javascript,text/css,text/javascript,text/js"

useSendfile="false"

compressionMinSize="500">

<UpgradeProtocol

className="org.apache.coyote.http2.Http2Protocol"

compression="on"

compressionMinSize="500"

keepAliveTimeout="60000"

maxConcurrentStreamExecution="200"

maxConcurrentStreams="200"

maxHeaderSize="1024000"

noCompressionUserAgents="gozilla,traviata"

useSendfile="false" />

<SSLHostConfig certificateVerification="none"

honorCipherOrder="true" protocols="TLSv1.1,TLSv1.2"

ciphers=
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA"
>

<Certificate

certificateKeystoreFile="conf/KeystoreFile.jks"

certificateKeystorePassword="xxxxxx"

certificateKeystoreType="JKS" />

</SSLHostConfig>

</Connector>

Request headers (from Chrome):
:authority: localhost:8443
:method: GET
:path: /tomcat.css
:scheme: https
accept: text/css,*/*;q=0.1
accept-encoding: gzip, deflate, br
accept-language: en-US,en;q=0.9
cache-control: no-cache
pragma: no-cache
referer: https://localhost:8443/
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36

Response headers (from Chrome):
accept-ranges: bytes
content-type: text/css
date: Wed, 25 Jul 2018 21:48:16 GMT
etag: W/"5931-1524878698000"
last-modified: Sat, 28 Apr 2018 01:24:58 GMT
status: 200


Thanks in advance.

Reply via email to