How to set hostHeader correctly for subdomains?

会有一股神秘感。 提交于 2019-12-11 05:15:42

问题


I have created a two sites like this:

<Sites>
  <Site name="WebRole" physicalDirectory="./WebRole">
    <Bindings>
         <Binding name="Endpoint1" endpointName="HttpEndpoint" />
    </Bindings>
  </Site>   
  <Site name="MySite" physicalDirectory="./MySite">         
      <Bindings>                     
         <Binding name="Endpoint" endpointName="HttpEndpoint"  hostHeader="www.MySite.com"/>                    
      </Bindings>     
  </Site>
</Sites>

I have changed my DNS under CNAME (Alias) -> www to xxx.cloudapp.net

Therefore when I type in www.MySite.com it gets to my cloud app, the hostHeader is recognized and goes to the right physical site. The HostHeader works fine.

Now I try to do the same thing as a subdomain.

<Site name="MySite" physicalDirectory="./MySite">       
        <Bindings>                   
            <Binding name="Endpoint" endpointName="HttpEndpoint"  hostHeader="sub.MySite.com"/>                     
        </Bindings>       
</Site>

In DNS manager I didn't try to do it in CNAME but instead I did a masked Forward of the sub domain to the same side's address xxx.cloudapp.net.

But this doesn't work. It simply open up the first Site instead. It seems the HostHeader is not understood in order to point to the second physical path.

What am I missing?


回答1:


As far as I can tell "masked forwarding" usually works by using frames, and if that's the case the host header information won't be forwarded to Azure.

Your DNS host will create a Web site with a frame, and the data for that frame will come from the xxx.cloudapp.net site. As there's no host header information forwarded the Azure load balancer won't be able to use the alternate site.

I'm afraid it looks like you'll need to use the CNAME system to explicitly forward the host names.



来源:https://stackoverflow.com/questions/8378228/how-to-set-hostheader-correctly-for-subdomains

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!