Azure Webapps上的Gzip

时间:2018-11-26 09:19:13

标签: azure compression gzip azure-webapps

我的Azure Webapps中的gzip存在问题。我正在使用Wordpress(我的域为https://www.uc.ac.id),并为我的Webapp使用Windows OS。

我无法在我的网站中启用gzip压缩。我尝试了很多方法来启用它(在我的web.config和application.xdt上添加压缩功能),但是在我签入https://checkgzipcompression.com后,该gzip无法启用。

请帮助我。

有我的web.config

 <?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
   <pages enableSessionState="false" />
</system.web>
  <system.webServer>
      <httpProtocol>
      <customHeaders>
        <clear />
        <remove name="X-Powered-By" />
        <add name="X-Frame-Options" value="SAMEORIGIN" />
        <add name="X-Xss-Protection" value="1; mode=block" />
        <add name="X-Content-Type-Options" value="nosniff" />
        <add name="Referrer-Policy" value="no-referrer" />
      </customHeaders>
      <redirectHeaders>
        <clear />
      </redirectHeaders>
    </httpProtocol>
    <security>
        <requestFiltering>
             <requestLimits maxAllowedContentLength="15000000" />
             <denyUrlSequences>
                <add sequence="xmlrpc.php" />
             </denyUrlSequences>
       </requestFiltering>
      <dynamicIpSecurity denyAction="Forbidden">
       <denyByConcurrentRequests enabled="true" maxConcurrentRequests="10" />
       <denyByRequestRate enabled="true" maxRequests="15" requestIntervalInMilliseconds="2000" />
     </dynamicIpSecurity>
    </security>
    <staticContent>
            <clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="31.00:00:00" />
            <remove fileExtension=".woff2" />
            <mimeMap fileExtension=".woff2" mimeType="font/woff2" />
            <remove fileExtension=".woff" />
            <mimeMap fileExtension=".woff" mimeType="font/woff" />
    </staticContent>
    <urlCompression doStaticCompression="true" doDynamicCompression="true" dynamicCompressionBeforeCache="true" />
      <rewrite>
      <rules>
        <rule name="ProxyAdmin" stopProcessing="true">
            <match url="developer-academy(.*)" />
            <action type="Rewrite" url="https://ucappleacademy.azurewebsites.net/{R:1}" logRewrittenUrl="false" />
        </rule>
        <rule name="Redirect rquests to default azure websites domain" stopProcessing="true">
            <match url="(.*)" />  
            <conditions logicalGrouping="MatchAny">
              <add input="{HTTP_HOST}" pattern="^semeru\.azurewebsites\.net$" />
            </conditions>
            <action type="Redirect" url="https://www.uc.ac.id/{R:0}" />  
        </rule>
            <rule name="WordPress: https://www.uc.ac.id" patternSyntax="Wildcard">
                <match url="*"/>
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
                    </conditions>
                <action type="Rewrite" url="index.php"/>
            </rule>
            </rules>
    </rewrite>
  </system.webServer>
</configuration>

这是我的application.xdt

    <?xml version="1.0"?>  
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">  
    <system.webServer>  
        <proxy xdt:Transform="InsertIfMissing" enabled="true" preserveHostHeader="false" reverseRewriteHostInResponseHeaders="false" />  
        <httpCompression>
            <dynamicTypes>
                <add mimeType="application/json;charset=utf-8" enabled="true" xdt:Transform="InsertAfter(/configuration/system.webServer/httpCompression/dynamicTypes/add[(@mimeType='application/json')])" />
                </dynamicTypes>
        </httpCompression>
    </system.webServer>  
</configuration>

0 个答案:

没有答案