iis cname到子域,从请求中获取子域 [英] iis cname to subdomain, get subdomain from the request

查看:165
本文介绍了iis cname到子域,从请求中获取子域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真正想做的是建立一个名为site.com的azure网站。然后有数百个子域名,如foo.site.com,bar.site.com,baz.site.com等。我的asp.net mvc应用程序将拉出子域,因为它将用作标识符。
接下来我想将其他域名CNamed到子域名。比如hello.othersite.com - > foo.site.com,这样浏览器仍会显示hello.othersite.com,但我可以从请求中获取foo子域名。

What I'd really like to do is set up an azure site called site.com. Then have hundreds of subdomains such as foo.site.com, bar.site.com, baz.site.com etc. My asp.net mvc application will pull out the subdomain as this will be used as an identifier. Next I'd like to have other domains CNamed to the subdomains. Such as hello.othersite.com -> foo.site.com, so that the browser still shows hello.othersite.com but I'd be able to get the foo subdomain out of the request.

我不想配置任何这个,因为会有很多子域名,基本上每个帐户一个。

I don't want to have to configure any of this because there are going to be lots of subdomains, essentially one per account.

是这有可能吗?

我已经尝试了一些测试,但我不是100%肯定如何继续。我只是:

I've tried a few tests but I'm not 100% sure how to proceed. Would I just:


  1. 设置site.com接受* .site.com

  2. CNAME你好.othersite.com到foo.site.com(我想要屏蔽,转发等吗?)

  3. 传入的http请求是否包含有关子域(foo)
    的任何信息它是CNAMED?

我希望这不是太模糊和浪漫,但对其合理性的一些确认将是一个很大的帮助。

I hope this isn't too vague and hand wavey but some confirmation of its plausibility would be a great help.

推荐答案

它不仅仅是Azure,而是整个网络。

It is not just Azure, but the whole web.

我不认为有可能退出 hello.othersite.com 的HTTP请求,它实际上在DNS中映射到 foo .site.com 。这是因为您的实际HTTP请求看起来像

I don't think it is possible to get out of the HTTP request for hello.othersite.com that it actually mapped in the DNS to foo.site.com. And this is because your actual HTTP request will look something like

GET /index.html HTTP/1.1
(other headers)
host: hello.othersite.com

您的网络服务器,无论它是什么,不知道 hello.othersites.com 是通过CNAME映射到 foo.site.com 。您收到的请求是 hello.othersite.com

Your web server, whatever it is, has no idea that hello.othersites.com is mapped via CNAME to foo.site.com. The request you receive is for hello.othersite.com.

如果您转发,用户将永远不会停留在 hello.othersite.com 上,但会被重定向到 foo.site.com 。我想这不是你想要的。

If you do forwarding, the users will never stay on hello.othersite.com but will be redirected to foo.site.com. I guess this is not what you want.

直接域掩码通常是通过iFrame完成的,也不建议使用。

Direct domain masking is usually done via iFrame, which would also not recommend.

我会做以下事情,因为目前没有其他想法:

I would do the following, as nothing else comes to mind at the moment:


  1. 设置网站接受 * .site.com *。othersite.com

  2. 添加通配符CNAME地图到我的Azure云服务,即 * .site.com - > CNAME - > my.cloudapp.net 。对于我想要的两个自定义域都相同。

  3. 在我的应用中执行必要的检查以确定域映射< - >用户帐户。

  1. Setup the site to accept *.site.com and *.othersite.com
  2. Add Wildcard CNAME map to my Azure cloud service, i.e. *.site.com -> CNAME -> my.cloudapp.net. Same for both custom domains I want to have.
  3. Perform necessary checks in my app to figure out domain mappings <-> user accounts.

这篇关于iis cname到子域,从请求中获取子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆