Azure - hostheader不接受没有www的主机

时间:2011-02-28 04:26:19

标签: azure

我已在服务定义文件中设置了主机头,如下所示:

<Site name="Example" physicalDirectory="..\example.WebUx">
 <Bindings>
   <Binding name="Example" endpointName="HttpIn" hostHeader="www.example.com" />
 </Bindings>
</Site>

当我进入www.example.com时,它会转到我角色的正确网站。然而,当我只输入没有www的example.com时,它会转到默认网站。我尝试了以下内容并没有帮助:

<Site name="Example" physicalDirectory="..\Example.WebUx">
 <Bindings>
   <Binding name="Example" endpointName="HttpIn" hostHeader="www.example.com" />
   <Binding name="Example" endpointName="HttpIn" hostHeader="example.com" />
 </Bindings>
</Site>

我尝试了以下内容,它出现了一条错误消息“错误1发现使用相同虚拟路径定义的重复网站元素'示例/'用于角色Default.WebUx

<Site name="Example" physicalDirectory="..\Example.WebUx">
 <Bindings>
   <Binding name="Example" endpointName="HttpIn" hostHeader="www.example.com" />
 </Bindings>
</Site>
<Site name="Example" physicalDirectory="..\Example.WebUx">
 <Bindings>
   <Binding name="Example" endpointName="HttpIn" hostHeader="example.com" />
 </Bindings>
</Site>

我尝试了以下内容并且无效。以这种方式实施时,www.example.com和example.com都转到了默认网站。

<Site name="Example" physicalDirectory="..\Example.WebUx">
 <Bindings>
   <Binding name="Example" endpointName="HttpIn" hostHeader="example.com" />
 </Bindings>
</Site>

我的想法很少:-(是否有人有设置hostHeader的经验,以便它可以接受我的网站的www和非www版本。

由于

这里有一些我也检查过的链接。不幸的是他们似乎没有帮助

Link 1

Link 2

3 个答案:

答案 0 :(得分:3)

我认为您不会使用域名来使用Azure DNS。

我可能有点过时了,但我相信让Azure DNS工作的方法是通过CNAME - 而CNAME适用于子域而不是域

答案 1 :(得分:2)

看起来你的绑定名称属性是相同的。

<Site name="Xxx" physicalDirectory="..\Xxx.WebUx">
 <Bindings>

   <Binding name="Xxx" endpointName="HttpIn" hostHeader="www.xxx.com" />

   <Binding name="THE_NEXT_NAME" endpointName="HttpIn" hostHeader="xxx.com" />

 </Bindings>
</Site>

答案 2 :(得分:0)

对于顶级域,您必须添加指向托管服务的虚拟IP的A记录。对于所有Web角色实例,这都是相同的。但是,这非常不稳定,因为如果删除部署,VIP将会更改。

我没有在网络角色中测试多个网站的顶级域名,因此不确定您是否仍会遇到此解决方案之外的主机标头问题。但上述内容适用于托管单个网站的Web角色。