2017-07-20 71 views
0

在我的开发机器上,我尝试将IIS配置为反向代理,将端口443中发出的请求转发到本地运行的nodejs应用程序。
请求转发得很好,但有时nodejs应用程序会尝试将浏览器重定向到外部站点,并且IIS url重写模块也会更改以指向本地服务器。IIS Url Rewrite覆盖外部URL Url

我访问使用https://localhost/test
IIS站点重新路由请求到节点应用http://localhost:14819/test
节点的应用程序返回一个HTTP 302位置标头设置为https://example.com/someroute
IIS转变这https://localhost/someroute

我想外部URL将不受IIS影响。这个怎么做? 这里是我的web.config内容

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <system.webServer> 
     <rewrite> 
      <rules> 
       <clear />     
       <rule name="ReverseProxyInboundRule1" patternSyntax="ECMAScript" stopProcessing="true"> 
        <match url="^test(.*)" /> 
        <conditions logicalGrouping="MatchAll" trackAllCaptures="false"> 
         <add input="{HTTP_HOST}" pattern="^localhost" /> 
        </conditions> 
        <action type="Rewrite" url="http://localhost:14819/test{R:1}" logRewrittenUrl="true" /> 
       </rule> 
      </rules>    
     </rewrite>   
    </system.webServer> 
</configuration> 

回答

1

如果您有任何重定向从后端代理回来,你 不想重定向位置头部来了,你可以做到这一点的 取消选中“逆rewritehost在应用 请求响应头”路由

  • 选择在IIS管理器的服务器节点
  • 转到应用程序请求路由缓存
  • 单击服务器代理服务器设置
  • 取消“响应头反向rewritehost”