如何识别服务器场中的哪个Web服务器提供请求?
我们正在调试在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.