是否可以指定(假冒)的用户代理使用IIS反向代理? [英] Is is possible to specify (fake) a User Agent using IIS Reverse Proxy?

查看:183
本文介绍了是否可以指定(假冒)的用户代理使用IIS反向代理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,是利用安装在IIS中的反向代理。 server1上的主网站将请求发送到文件夹到Server2。这是按预期工作,有一个奇怪的例外:

I've got a site that is setup using a reverse proxy in IIS. The main site on server1 sends requests to "folder" to server2. This is working as expected, with one strange exception:

Server2上的应用程序是旧的。它使用code,从.NET Framework 1.1和是,出于显而易见的原因,不再支持某些第三方控件。

The app on server2 is old. It is using code from .NET Framework 1.1 and some 3rd party controls that are, for obvious reasons, no longer supported.

当浏览服务器1 /文件夹中的IE浏览器(所有版本)随机事情可能发生,相当定期得到一个404错误。在浏览网站在Chrome的东西的工作只是预期。如果我告诉IE浏览器使用Chrome浏览器的用户代理它的表现通常为好。

When browsing server1/folder in IE (any version) random things may happen and get a 404 error fairly regularly. When browsing the site in Chrome things work just as expected. If I tell IE to use the Chrome User Agent it behaves normally as well.

我认为正在发生的是其中一个控件是看用户代理和做一些与它的现代IE浏览器,在反向代理失败。 (反向代理之前,它曾在IE浏览器)。作为最好的,我可以告诉,Server2上的配置是一样的,因为它是移动的代理了。

What I think is happening is that one of the controls is looking at the User Agent and doing something with it and failing with the modern IE over reverse proxy. (Before reverse proxy it worked in IE). As best I can tell, the configuration on server2 is the same as it was before the move to the proxy.

那么,有没有一种方法来伪造,欺骗,或将请求传递在Server1到Server2时以其他方式操纵用户代理?

So, is there a way to fake, spoof, or otherwise manipulate the User Agent when passing the request from server1 to server2?

推荐答案

解决方案是非常简单。

The solution was simple enough.

在IIS中的URL重写配置华而不实查看服务器变量...在右手列。点击添加,然后输入服务器变量的名称 - 在这种情况下HTTP_USER_AGENT

In IIS in the URL Rewrite configuration slick View Server Variables... in the right hand column. Click add and enter the name of the Server Variable - in this case HTTP_USER_AGENT.

这将允许您在布线过程中使用和/或修改此特定的服务器变量。这是我错过了,还是错之前得到的步骤。据我所知,这不可能在web.config文件中完成。我敢肯定有一个命令行来做到这一点,但我不知道。

This will allow you to use and/or modify this specific server variable during the routing process. This is the step that I had missed, or gotten wrong before. To my knowledge this can't be done in the web.config file. I'm sure there's a command line to do it, but I don't know that.

在加入HTTP_USER_AGENT到允许服务器变量列出它只是设置,要么通过IIS或在Web.config文件所需的值添加到服务器变量部分的问题。

After adding HTTP_USER_AGENT to the allowed server variables list it is just a matter of setting that either through IIS or in the Web.config file add the desired value to the server variables section.

<rule name="..." enabled="true" stopProcessing="true">
  <match url="[pattern]" />
  <action type="Rewrite" url="[destination]/{R:1}" />
  <serverVariables>
    <set name="HTTP_USER_AGENT" value="[desired value]" />
  </serverVariables>
</rule>

够简单了之后,我发现你不得不允许使用服务器变量。

Simple enough after I found out you had to "allow" the use of a server variable.

这篇关于是否可以指定(假冒)的用户代理使用IIS反向代理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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