在Tomcat中可以使用https进行gzip压缩吗? [英] Is gzip compression with https possible in Tomcat?
本文介绍了在Tomcat中可以使用https进行gzip压缩吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以为https配置Tomcat(7.0.75)并同时启用 gzip压缩?我无法找出 server.xml
中http连接器属性的有效组合来完成工作。可在http:
Is it possible to configure Tomcat (7.0.75) for https and enable gzip compression simultaneously? I can't figure out a valid combination of http connector properties in server.xml
to get the job done. The four compression-related properties that work on http:
compression="on"
compressableMimeType="application/json"
compressionMinSize="8192"
useSendfile="false"
似乎没有任何作用。我当前的配置:
don't seem to have any effect when https is configured. My current config:
<Connector port="8443"
protocol="HTTP/1.1"
SSLEnabled="true"
maxThreads="50"
server="web"
allowTrace="false"
keystoreFile="/app/certs/keystore.jks"
keystorePass="********"
scheme="https"
secure="true"
clientAuth="false"
sslProtocol="TLS"
sslEnabledProtocols="TLSv1.1,TLSv1.2"
ciphers="TLS_..._SHA"
maxKeepAliveRequests="100"
connectionTimeout="20000"
compression="on"
compressableMimeType="application/json"
compressionMinSize="8192"
useSendfile="false"
maxSwallowSize="-1"
socket.soKeepAlive="true"/>
推荐答案
我使用 server.xml的此配置:
1。 http连接器
<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000"
compression="on" compressionMinSize="0" useSendfile="false"
redirectPort="443" />
2。 https连接器
<Connector port="443" protocol="org.apache.coyote.http11.Http11AprProtocol"
maxThreads="200" SSLEnabled="true" connectionTimeout="20000"
compression="on" compressionMinSize="0" useSendfile="false" >
<SSLHostConfig>
<Certificate certificateKeyFile="conf/key.crt"
certificateFile="conf/certificate.crt"
certificateChainFile="conf/chain.crt"
type="RSA" />
</SSLHostConfig>
</Connector>
您可能希望将端口 80
更改为 8080
,并将端口 443
移植到 8443
。
You may want to change port 80
to 8080
, and port 443
to 8443
.
UPD::如果您使用 http2
协议-也添加以下行:
UPD: If you use http2
protocol - add this line too:
<UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol"
compression="on" compressionMinSize="0" useSendfile="false" />
这篇关于在Tomcat中可以使用https进行gzip压缩吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文