iis - Azure 网站上的 URL 重写到另一台服务器

标签 iis azure ember.js url-rewriting

我有一个 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 重写或访问其他服务器的限制?

最佳答案

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

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

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

关于iis - Azure 网站上的 URL 重写到另一台服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27479469/

相关文章:

c# - IIS/Azure 云中是否允许 System.IO.File 访问?

powershell - Get-IISAppPool属性 “Status”始终为空

iis - 经典 ASP "Down for Maintenance"页面

c# - 当文件上传到 azure 文件共享时,如何添加触发器以将文件从 azure 文件共享移动到 azure blob?

parsing - 如何以 Python 方式处理 IIS 日志解析?

Azure 移动服务、数据库选项

Azure服务总线: How to correctly check if Subscription already exists?

ruby-on-rails - 使用 Ember 从服务器获取 JSON 数据

javascript - Ember JS 错误处理 : Accessing errors in model not possible due to adapter error

javascript - 你如何强制 Ember 重新渲染一个组件?