IIS反向代理到Node.js-静态压缩 Windows Server 2012 IIS 8.5
我们将IIS设置为Node.js web服务器的反向代理(两者运行在同一个框中)。我无法通过IIS对Node.js提供的资源进行静态压缩IIS反向代理到Node.js-静态压缩 Windows Server 2012 IIS 8.5,node.js,iis,Node.js,Iis,我们将IIS设置为Node.js web服务器的反向代理(两者运行在同一个框中)。我无法通过IIS对Node.js提供的资源进行静态压缩 为了重写请求URL,我们使用URL重写模块和入站规则。 没有出站规则 Node.js中禁用了压缩-我们希望IIS对Node.js的响应进行压缩 我们已经测试了动态压缩(使用默认的GZip压缩),一切正常。 当入站规则被禁用时,静态压缩正在工作,但仅适用于IIS站点本地的文件(即Node.js中未提供的文件)。 这说明“Oubound重写不能与IIS静态压缩一
- 为了重写请求URL,我们使用URL重写模块和入站规则。 没有出站规则
- Node.js中禁用了压缩-我们希望IIS对Node.js的响应进行压缩
- 我们已经测试了动态压缩(使用默认的GZip压缩),一切正常。
- 当入站规则被禁用时,静态压缩正在工作,但仅适用于IIS站点本地的文件(即Node.js中未提供的文件)。
- 这说明“Oubound重写不能与IIS静态压缩一起使用。”但是,我们没有任何出站规则
- 我已启用失败的请求跟踪,但在启用入站规则时,无法在跟踪中看到任何静态\u压缩\u开始项
- 在IIS web服务器配置中,我尝试了各种设置,例如staticCompressionIgnoreHitFrequency=“true”,请参见下面的示例李>
<httpCompression directory="C:\inetpub\temp\IIS Temporary Compressed Files" minFileSizeForComp="1" noCompressionForHttp10="false" noCompressionForProxies="false" noCompressionForRange="false" staticCompressionIgnoreHitFrequency="true" staticCompressionEnableCpuUsage="1" >
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" staticCompressionLevel="9" />
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="application/atom+xml" enabled="true" />
<add mimeType="application/xaml+xml" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
<dynamicTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
</httpCompression>
网站web.config中的示例:
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear></clear>
<rule name="ReverseProxyInboundRule1" enabled="false" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://localhost:3000/{R:1}" />
</rule>
</rules>
</rewrite>
<urlCompression doStaticCompression="true" doDynamicCompression="false" />
</system.webServer>
</configuration>
我尝试使用IIS作为另一个IIS站点(而不是节点)的反向代理,并在此处粘贴了一个相关问题: 这导致了上述节点问题的解决。您需要: 1) 忘记静态压缩模块(在反向代理使用ARR时禁用),而是启用ARR缓存(启用压缩)。这将Gzip ARR缓存的内容但是 2) 我注意到这对JS文件不起作用。原因是我们的节点服务器将JS文件的内容类型设置为“application/javascript;charset=UTF-8”。默认情况下,ARR配置为查找不带字符编码的内容类型 要解决此问题,请在\Windows\System32\inetsrv\config\applicationHost.config中,根据以下内容添加
映射:
<diskCache>
<driveLocation path="C:\inetpub\arrCache" maxUsage="5" />
<compression>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="application/javascript; charset=UTF-8" enabled="true" />
</compression>
</diskCache>