IIS AAR - 用于反向代理的URL重写 - 如何发送HTTP_HOST [英] IIS AAR - URL Rewrite for reverse proxy - how to send HTTP_HOST

查看:1229
本文介绍了IIS AAR - 用于反向代理的URL重写 - 如何发送HTTP_HOST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在几个后端IIS服务器前使用AAR作为反向代理。

Trying to use AAR as a reverse proxy in front of several back end IIS servers.


  • 分配了一个公共IP地址运行IIS / AAR的服务器

  • One public ip address assigned to the server running IIS/AAR

然后设置出站URL重写规则,根据主机名重定向到
多个后端服务器之一。

Then outbound URL rewrite rules are setup to redirect to one of several back end servers depending on hostname.

工作有点,但总是返回后端服务器默认站点(不是映射到主机名的站点)所以看起来就像主机名(HTTP_HOST)没有从代理服务器传递到后端服务器。

Works somewhat, but always returns the back end servers default site (not the one mapped to a hostname) so it looks like the host name (HTTP_HOST) is not getting passed from the proxy server to the back end server.

(我已通过编辑绕过反向代理验证主机和后端服务器返回绑定到主机头的正确站点)

这是规则的一个示例(192.168.0.99是内部服务器) ,site.myco.com是主机名)

This is an example of the rule (192.168.0.99 is the internal server, site.myco.com is the hostname)

    <rewrite>
        <rules>
            <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                <match url="(.*)" />
                <action type="Rewrite" url="http://192.168.1.99/{R:1}" />                   
            </rule>
        </rules>
    </rewrite>

尝试过设置服务器变量

    <!-- Guessing server.myco.com is hard coded -->
    <serverVariables>
        <set name="HTTP_HOST" value="server.myco.com" />
    </serverVariables>

    <!-- Guessing picked up dynamically from incoming request host header -->
    <serverVariables>
        <set name="HTTP_HOST" value="{HTTP_HOST}" />
    </serverVariables>

但是唉总是返回默认绑定 - 任何想法?

But alas always returns the default binding - any ideas?

推荐答案

这篇文章有答案 - 使用IIS7应用程序请求路由修改标头

This post has the answer - Modifying headers with IIS7 Application Request Routing

需要启用preserveHostHeader - 无法在UI中看到您如何执行此操作

Need to enable preserveHostHeader - can't see how you do that in the UI but this works

从命令行运行此更新机器/ webroot / apphost配置

Run this from command line to update Machine/webroot/apphost config

%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/proxy -preserveHostHeader:true /commit:apphost

这篇关于IIS AAR - 用于反向代理的URL重写 - 如何发送HTTP_HOST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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