英文:
IIS Server Farm - URL Rewrite
问题
我正在尝试创建一个IIS服务器群集,并且在使URL重写正常工作方面遇到了问题。
Windows 10企业版
IIS 10
以下是相关的配置。
<applicationPools>
<add name="always-blue" autoStart="true">
<processModel pingingEnabled="true" pingResponseTime="00:01:30" />
</add>
<add name="always-green" autoStart="true">
<processModel pingingEnabled="true" pingResponseTime="00:01:30" />
</add>
</applicationPools>
<sites>
<site name="always-blue" id="2" serverAutoStart="true">
<application path="/" applicationPool="always-blue">
<virtualDirectory path="/" physicalPath="C:\xxx\always-up-blue" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:alwaysup-blue" />
</bindings>
</site>
<site name="always-green" id="3" serverAutoStart="true">
<application path="/" applicationPool="always-green">
<virtualDirectory path="/" physicalPath="C:\xxx\always-up-green" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:alwaysup-green" />
</bindings>
</site>
</sites>
<rewrite>
<globalRules>
<rule name="alwaysup rewrite" stopProcessing="false">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^alwaysup$" />
<add input="{SERVER_PORT}" pattern="^80$" />
</conditions>
<action type="Rewrite" url="http://alwaysup/{R:0}" />
</rule>
</globalRules>
</rewrite>
http://alwaysup-blue 和 http://always-green 网站都正常运行。然而,服务器群集不起作用。http://alwaysup 返回502错误。我检查了带有FailTracedURLs的日志,但无法理解其中的内容。以下是日志链接:
英文:
I am trying to create IIS Server Farm, and having issues with the URL Rewrite to work correctly.
Windows 10 Enterprise
IIS 10
Below is the relevant configurations.
<applicationPools>
<add name="always-blue" autoStart="true">
<processModel pingingEnabled="true" pingResponseTime="00:01:30" />
</add>
<add name="always-green" autoStart="true">
<processModel pingingEnabled="true" pingResponseTime="00:01:30" />
</add>
</applicationPools>
<sites>
<site name="always-blue" id="2" serverAutoStart="true">
<application path="/" applicationPool="always-blue">
<virtualDirectory path="/" physicalPath="C:\xxx\always-up-blue" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:alwaysup-blue" />
</bindings>
</site>
<site name="always-green" id="3" serverAutoStart="true">
<application path="/" applicationPool="always-green">
<virtualDirectory path="/" physicalPath="C:\xxx\always-up-green" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:alwaysup-green" />
</bindings>
</site>
</sites>
<rewrite>
<globalRules>
<rule name="alwaysup rewrite" stopProcessing="false">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^alwaysup$" />
<add input="{SERVER_PORT}" pattern="^80$" />
</conditions>
<action type="Rewrite" url="http://alwaysup/{R:0}" />
</rule>
</globalRules>
</rewrite>
Both http://alwaysup-blue and http://always-green websites are up and work normal. However the server farm doesn't work. http://alwaysup -> Returns 502. I checked the logs with FailTracedURLs, but couldn't make much sense of that. Here are the logs ..
答案1
得分: 0
跟踪警告: REWRITE_DISABLED_KERNEL_CACHE
这个警告表示:如果一个重写规则集使用了列表中未提及的任何服务器变量,那么该规则集被认为对输出缓存是不安全的。这意味着URL重写模块将禁用内核模式缓存,无论请求的URL是否被重写。参考:与IIS输出缓存的交互。
但我认为这个警告并不是502错误的根本原因,问题应该出在你的部署过程中。我按照教程在IIS中使用了蓝绿部署,没有发生错误。你可以尝试按照此链接中的步骤重新部署:如何在IIS中使用蓝绿部署。
英文:
> trace warning: REWRITE_DISABLED_KERNEL_CACHE
This warning indicates: if a rewrite rule set uses any server variable not mentioned in the list, the rule set is considered unsafe for output caching. This means that the URL Rewrite Module will disable kernel mode caching for all requests whether the request URLs were rewritten or not. Refer to: Interaction with IIS Output Caching
But I don't think this warning is the root cause of 502 error, the problem should be in your deployment process. I followed the tutorial to use blue-green deployment in IIS and no error occurred. You can try redeploying by following the steps in this link: How to use Blue-Green Deployment in IIS.
答案2
得分: 0
在配置的webfarm部分中添加了preserveHostHeader。
英文:
<webFarms>
<webFarm name="alwaysup" enabled="true">
<server address="alwaysup-blue" enabled="true">
<applicationRequestRouting hostName="alwaysup-blue" httpPort="8081" />
</server>
<server address="alwaysup-green" enabled="true">
<applicationRequestRouting hostName="alwaysup-green" httpPort="8082" />
</server>
<applicationRequestRouting>
<healthCheck url="http://alwaysup/up.html" responseMatch="up" />
<loadBalancing />
<protocol preserveHostHeader="false">
<cache enabled="true" validationInterval="00:01:00" />
</protocol>
</applicationRequestRouting>
</webFarm>
Had to add the preserveHostHeader to webfarm section of configuration.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论