问题
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