我有一个IIS Web服务器,可以处理对* .myapp.com的所有请求。我们还有设置自定义域名的客户,例如custom.customer.com作为CNAME到customer.myapp.com
我需要处理以下内容:
我现在遇到的问题是,这不能在DNS级别上完成(因为它涉及路径)。此外,无论“重定向”是什么,我希望客户端始终能够看到他的自定义域。就像他永远不会看到internal-app.com或myapp.com。
这有可能吗?
答案 0 :(得分:1)
可以使用反向代理。
1)您需要为IIS安装URL Rewrite和ARR module
2)启用ARR。在Application Request Routing
页面上,选择Enable proxy
3)创建重写规则
<rewrite>
<rules>
<rule name="rewrite custom.customer.com/patha" stopProcessing="true">
<match url="patha" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^custom.customer.com$" ignoreCase="true" />
</conditions>
<action type="Rewrite" url="http://a.internal-app.com/" />
</rule>
<rule name="rewrite custom.customer.com/pathB" stopProcessing="true">
<match url="pathb" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^custom.customer.com$" ignoreCase="true" />
</conditions>
<action type="Rewrite" url="http://b.internal-app.com/" />
</rule>
</rules>
</rewrite>
P.S。您的资源可能有问题(图像,样式,CSS,js)。因为你的html可能包含资源的绝对路径
当作者创建用于修复相对网址https://blogs.iis.net/carlosag/setting-up-a-reverse-proxy-using-iis-url-rewrite-and-arr的出站规则时,您可以查看此帖子