conf/server.xml中,Connector的配置中添加
compression="on" compressionMinSize="512" noCompressionUserAgents="gozilla, traviata"
实际的例子:
<Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol" connectionTimeout="20000" redirectPort="8443" maxHttpHeaderSize ="8192" maxThreads ="4096" minSpareThreads ="512" enableLookups ="false" acceptCount ="512" disableUploadTimeout ="true" compression="on" compressionMinSize="512" noCompressionUserAgents="gozilla, traviata" /> <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol" SSLEnabled="true" connectionTimeout="20000" maxThreads="4096" maxHttpHeaderSize ="8192" minSpareThreads ="512" compression="on" compressionMinSize="512" noCompressionUserAgents="gozilla, traviata" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" ciphers="TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA256,TLS_RSA_WITH_AES_256_CBC_SHA" keystoreFile="${catalina.base}/keystore/xxx.p12" keystorePass="111" keystoreType="PKCS12" />