2017-08-25 104 views
0

是否可以为https:同时启用gzip压缩来配置Tomcat(7.075)?我无法弄清server.xml中http连接器属性的有效组合,以完成工作。四个与压缩相关的属性可用于http:使用https可能的Tomcat进行gzip压缩

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

相关https://stackoverflow.com/questions/2767211/can-you-use-gzip-over-ssl-and-connection-keep-alive-headers – Hackerman

回答

0

我使用这种配置的变体。它工作正常,我:

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> 

您可能需要更改端口808080和端口4438443