【问题标题】:URL rewrite on an Azure Website to another server将 Azure 网站上的 URL 重写到另一台服务器
【发布时间】:2014-12-15 07:46:58
【问题描述】:

我有一个 Ember 应用程序,它使用 CORS 访问不同子域上的 API。 由于 IE8 和 IE9 没有完整的 CORS 支持,我需要创建一个代理来访问 API。

Ember 应用程序部署在 Azure 网站上,API 是 Web 角色。我尝试使用 URL 重写创建代理,但只得到 404 Not Found。

我想要以下行为

https://www.cloudstorez.com/rewrite/cms/public/designs

重写为

https://cms-public.cloudstorez.com/designs

URL 重写如下所示

<rule name="Rewrite to APIs" stopProcessing="true">
    <match url="^rewrite/([^/]*)/([^/]*)/(.*)" />
    <action type="Rewrite" url="https://{R:1}-{R:2}.cloudstorez.com/{R:3}" />
</rule>

如果我改为进行相应的重定向,它就可以正常工作。

<rule name="Redirect to APIs" stopProcessing="true">
    <match url="^redirect/([^/]*)/([^/]*)/(.*)" />
    <action type="Redirect" url="https://{R:1}-{R:2}.cloudstorez.com/{R:3}" />
</rule>

我的重写是否有问题,或者 Azure 网站是否有关于 URL 重写或访问其他服务器的限制?

【问题讨论】:

    标签: iis azure ember.js url-rewriting


    【解决方案1】:

    重写到外部 URL 称为反向代理。此功能是通过 ARR + Url Rewrite 的组合来实现的。这是 IIS 的两个独立模块。

    Azure 网站默认不启用反向代理。但是有一个技巧可以启用它。来自 IIS 团队(或前 IIS 团队)的 Ruslan Y. 在how to enable reverse proxy on Azure Web Sites here 上写了一篇博文。

    注意 - 我没有亲自测试过这个技巧,所以不能说它是否仍然有效(自 Ruslan 的博客以来,Azure 网站已经有了很大的发展,此功能可能已被禁用),但仍然值得一试。

    【讨论】:

    • 我刚刚尝试了这个技巧,直到今天(2016 年 6 月)它仍然有效。谢谢!
    猜你喜欢
    • 2012-01-25
    • 1970-01-01
    • 2021-11-04
    • 2015-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-05
    相关资源
    最近更新 更多