如何识别服务器场中的哪个 Web 服务器处理了请求? [英] How to identify which web server in a farm served a request?
问题描述
我们正在调试在 IIS7 上运行的网站的间歇性问题.
We're debugging intermittent issues with a website running on IIS7.
由于负载均衡器后面有许多节点,我们无法判断哪个主机响应了给定请求.在 IIS 级别有什么方法可以指定哪个主机服务于请求?例如,IIS 是否可以在响应中附加一个标头来指示发送响应的主机的 IP?
Since we have many nodes behind the load balancer, we can't tell which host responded to a given request. Is there any way at the IIS level to specify which host served a request? For example, could IIS append a header in the response that indicates the IP of the host that sent the response?
理想情况下,我想要一个不需要任何编码的解决方案.
Ideally, I would like a solution that does not require any coding.
推荐答案
无需编写任何代码,您只需在 IIS 管理器中为每台计算机配置自定义 HTTP 响应标头即可.您需要使用 GUI 或 APPCMD.EXE
手动输入每个 IP 地址或标识符.这可以在全球范围内为所有站点完成:
Without writing any code you could just configure a custom HTTP Response Header for each machine in IIS Manager. You'd need to manually enter each IP address or identifier manually using either the GUI or APPCMD.EXE
. This can be done globally for all sites:
appcmd.exe set config -section:system.webServer/httpProtocol
/+"customHeaders.[name='X-Custom-Name',value='MyCustomValue']"
或者对于单个站点:
appcmd.exe set config "Default Web Site" -section:system.webServer/httpProtocol
/+"customHeaders.[name='X-Custom-Name',value='MyCustomValue']"
为了适应它们,我将这些命令分成两行.您应该将它们作为一行输入.
I've split these commands over two lines just to fit them in. You should enter them as a single line.
这篇关于如何识别服务器场中的哪个 Web 服务器处理了请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!