在IIS中向本地TomCat反向代理

IIS有几个网站:

  • domain1.com
  • a.domain2.com
  • b.domain2.com

还有一个TomCat正在运行

localhost:8087 

挑战是如何将TomCat外部公开为

 b.domain2.com 

我做了什么:

  • 在IIS中的ARR中启用代理
  • 在b.domain2.com上添加了反向代理URL重写规则

     <rewrite> <rules> <rule name="ReverseProxyInboundRule1" stopProcessing="true"> <match url="(.*)" /> <action type="Rewrite" url="http://localhost:8087/{R:1}" /> </rule> </rules> <outboundRules> <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1" > <match filterByTags="A, Form, Img" pattern="^http(s)?://localhost:8087/(.*)" /> <action type="Rewrite" value="http{R:1}://femiscan.a2itsolutionsllc.com/{R:2}" /> </rule> <preConditions> <preCondition name="ResponseIsHtml1"> <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" /> </preCondition> </preConditions> </outboundRules> </rewrite> 

我所看到的:

如果我导航到本地

 http://b.domain2.com 

我的浏览器显示为TomCat网站

 http://localhost:8087 

(为什么?)

外部如果我在Chrome导航

 http://b.domain2.com 

它试图通过隧道

 http://localhost:8087 

如果我在IE中导航,它返回500错误(提琴手:HTTP / 1.1 500 URL重写模块错误。)

问题:我做错了什么? 它可以做,如何?

您的操作设置为重写,因此它正在重写URL。

在IISpipe理器中:

  • 右键单击服务器场,单击“创build服务器场”。 给它一些名字。
  • 将完全限定的域名放入“服务器名称或地址”域中的Tomcat实例
  • 点击“高级设置…”,展开“applicationRequestRouting”并将httpPort更改为8087
  • 提示创build重写规则时,单击“是”
  • 单击窗口左侧窗格中“服务器场”下新build的服务器场
  • 在服务器场function视图页面上打开“路由规则”
  • 点击右侧窗格中的“URL Rewrite …”链接
  • 删除旧的尝试Tomcat重写规则
  • 点击右侧窗格顶部的“添加规则…”,select“空白规则”
  • 给它一个名字
  • 在“匹配URL”窗格中:
    • 请求的URL: Matches the Pattern
    • 使用: Regular Expressions
    • 模式: *
  • 展开条件窗格,点击“添加”
    • 条件input: {HTTP_HOST}
    • 检查inputstring: Matches the pattern
    • 模式: b.domain2.com
    • 检查Ignore Case
  • 在“操作”窗格中:
    • 操作types: Route to Server Farm
    • 计划: http://
    • 服务器场:( (the name of your server farm)
    • path: {R:1}注:这可能需要一些修补,但从你的例子来看,它应该工作)
  • 点击右侧窗格中的“应用”和您的