通过反向代理访问时,jQuery脚本被切断 [英] JQuery script getting cut off when accessed via reverse proxy

查看:171
本文介绍了通过反向代理访问时,jQuery脚本被切断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在wwwdev.example.com上运行了一个反向代理服务器,而在dev.example.com上运行了完整的站点。如果我转到dev.example.com/scripts/jquery-version.js,则会得到完整的jQuery-version.js文件,返回结果如下:

We have a reverse proxy server running on wwwdev.example.com, and we have the full site running on dev.example.com. If I go to dev.example.com/scripts/jquery-version.js, I get the full jQuery-version.js file returned, ending like this:

if ( typeof define === "function" && define.amd && define.amd.jQuery ) {
    define( "jquery", [], function () { return jQuery; } );
}

})( window );

如果我去wwwdev.example.com/scripts/jquery-version.js,文件是在完成之前将其删除:

If I go to wwwdev.example.com/scripts/jquery-version.js, the file is cut off before it completes:

if ( typeof define === "function" && define.amd && define.amd.jQuery ) 

唯一相关的入站规则如下:

The only relevant inbound rule follows:

<rule name="ReverseProxyInboundRule1" enabled="true" stopProcessing="true">
    <match url="(.*)" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
        <add input="{HTTP_HOST}" pattern="^(.+?\.)?wwwdev\.example\.com" />
    </conditions>
    <serverVariables>
        <set name="HTTP_ACCEPT_ENCODING" value="" />
        <set name="HTTP_X_PROXY_REQUEST" value="" />
    </serverVariables>
    <action type="Rewrite" url="http://{C:1}dev.example.com/{R:1}" logRewrittenUrl="true" />
</rule>

唯一相关的出站规则如下:

The only relevant outbound rule follows:

<rule name="Rewrite Links in JS" preCondition="IsJavascript" enabled="true">
    <match filterByTags="None" pattern="&quot;/(.+)&quot;" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="true" />
    <action type="Rewrite" value="&quot;http://wwwdev.example.com/{R:1}&quot;" />
</rule>
<preConditions>
    <preCondition name="IsJavascript">
        <add input="{RESPONSE_CONTENT_TYPE}" pattern="^application/x-javascript" />
    </preCondition>
</preConditions>

静态压缩已启用;动态压缩已关闭。我也尝试过关闭静态压缩,但这似乎并不会影响此结果。

Static compression is on; dynamic compression is off. I've tried turning static compression off as well, but that doesn't seem to affect this result.

当我使用Fiddler捕获时,可以看到返回的完整文件,但它无法通过浏览器(即IE或Chrome)实现。我确实通过Fiddler报告了Content-Length不匹配的情况( Response Header指示266,885字节,但服务器发送了266,961字节),我认为这是相关的,但我不是确定原因是什么。

When I capture with Fiddler, I can see the full file returned, but it doesn't make it through the browser (IE or Chrome). I do get a Content-Length mismatch reported through Fiddler (Response Header indicated 266,885 bytes, but server sent 266,961 bytes), which I would assume is relevant, but I'm not sure what's causing the issue.

任何想法都会受到赞赏-这让我发疯。

Any ideas would be GREATLY appreciated - this has been driving me nuts.

推荐答案

找到答案此处

在IIS服务器节点的应用程序请求路由缓存功能下的服务器代理设置下,需要将响应缓冲区阈值(KB)设置为4096(以匹配响应缓冲区(KB))

Under the Application Request Routing Cache feature of the IIS server node, under Server Proxy Settings, Response buffer threshold (KB) needs to be set to 4096 (to match the Response buffer (KB)).

这篇关于通过反向代理访问时,jQuery脚本被切断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆