是否可以为https配置Tomcat(7.075) AND 同时启用gzip压缩?我无法找出server.xml中http连接器属性的有效组合来完成工作。与http:
相关的四个与压缩相关的属性compression="on"
compressableMimeType="application/json"
compressionMinSize="8192"
useSendfile="false"
配置https时似乎没有任何效果。我当前的配置:
<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"/>
答案 0 :(得分:2)
我使用 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
UPD :如果您使用http2
协议,请添加此行:
<UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol"
compression="on" compressionMinSize="0" useSendfile="false" />