Logo

IIS实现反向代理

photo
Pastore Antonio

2021年04月04日

新建两个站点,端口分别使用 80 和 81,在DNS中新建A记录,指向该计算机(10.4.34.41)

配置过程如下:

1.在Windows Server 2012 R2上 安装ARR,URL Rewriter组件。

  ARR3.0需要如下组件支持:Web Farm Framework 2.2(该组件又需要Web Platform Installer 3.0 和 WebDeploy 2.0组件的支持)

  URL Rewriter2.0(For IIS7.0,支持Win 2012 R2)直接安装即可。

  下载地址:http://www.iis.net/downloads/microsoft/application-request-routing

         http://www.iis.net/downloads/microsoft/web-farm-framework

         http://www.microsoft.com/en-us/download/details.aspx?id=7435
 
 依次安装完如上组件后,可以在IIS控制台中看到 ARR 和 URL重写 安装成功
 
 
2.启用ARR:打开ARR,然后在右侧对其启用(使用默认设置即可)
 
3.配置 URL重写,对URL进行过滤,将不同的访问请求(根据URL(DNS中的配置)进行过滤)定向到相应的站点
   该设置表明只有HTTP_HOST为la80.ddv.com的URL才能通过该规则,如果绑定了多个域名,可以根据多次增加或者通过正则表达式的 | 来间隔
 {R:1}表示了Match Url 中的第一个匹配括号

配置完成后如下图:

 

在外部访问 la80.ddv.com 和la81.ddv.com可以访问成功。

 

通过配置web.config文件,也可以实现 URL重写,如下:

      <rewrite>
        <rules>
          <rule name=”phpweb”>
            <match url=”^(.*)” />
            <conditions>
              <add input=”{HTTP_HOST}” pattern=”^phpweb.leven.com.cn$” />
            </conditions>
            <action type=”Rewrite” url=”http://localhost:8081/{R:1}” />
          </rule>
        </rules>
      </rewrite>

参考来源:http://blog.sina.com.cn/s/blog_532f78a40100rlpn.html

 

ARR安装完成后,如果在IIS里面看不到ARR图标,解决方法如下

1.分别通过如下命令打开 IIS管理器,查看有无ARR图标:

%windir%\System32\inetsrv\iis.msc
%windir%\system32\inetsrv\InetMgr.exe

2.通过PS脚本检查ARR是否安装成功:

$dll=[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.Web.Administration”)
#Get the manager and config object
$mgr = new-object Microsoft.Web.Administration.ServerManager
$conf = $mgr.GetApplicationHostConfiguration()
#Get the webFarms section
$section = $conf.GetSection(“webFarms”)
$section

 

本文为原创文章,请注意保留出处!
修复群晖Synology Drive client右键菜单缺失问题 Local, clean & environmental 作者:Pastore Antonio
1806 浏览量
1779 浏览量
configure: error: Package requirements (oniguruma) were not met Local, clean & environmental 作者:Pastore Antonio
1524 浏览量
Adobe Acrobat Pro 激活 Local, clean & environmental 作者:Pastore Antonio
1519 浏览量
追寻日出,找回自己 Local, clean & environmental 作者:Pastore Antonio
1488 浏览量