Webrole - Multiple hostHeader on a single Binding? - azure

Is it possible in Azure to have multiple hostHeader on a single Binding or is it mandatory to create one Binding for each hostheader ?
Example :
<Sites>
...
<Site name="sample.com" physicalDirectory="..\sample.com">
<Bindings>
<Binding name="ep_sample" endpointName="Endpoint1" hostHeader="www.sample1.com,www.sample2.com,www.sample3.com" />
</Bindings>
</Sites>
Or do I have to create each binding entry for single hostHeader (knowing that the site path is the same)?

I believe it has to be done like this:
<Sites>
...
<Site name="sample.com" physicalDirectory="..\sample.com">
<Bindings>
<Binding name="ep_sample1" endpointName="Endpoint1" hostHeader="www.sample1.com" />
<Binding name="ep_sample2" endpointName="Endpoint1" hostHeader="www.sample2.com" />
</Bindings>
</Sites>

Related

Setting IIS Application VirtualDirectory physicalpath

I have a .bat file with the following line that runs appcmd to install the sites contained in sites.xml
%windir%\system32\inetsrv\appcmd add site /in < .\sites.xml
sites.xml contains the following
<?xml version="1.0" encoding="UTF-8"?>
<appcmd>
<SITE SITE.NAME="Default Web Site" SITE.ID="1" bindings="http/*:80:,net.tcp/808:*,net.pipe/*,net.msmq/localhost,msmq.formatname/localhost,https/*:443:" state="Started">
<site name="Default Web Site" id="1" serverAutoStart="true">
<bindings>
<binding protocol="http" bindingInformation="*:80:" />
<binding protocol="net.tcp" bindingInformation="808:*" />
<binding protocol="net.pipe" bindingInformation="*" />
<binding protocol="net.msmq" bindingInformation="localhost" />
<binding protocol="msmq.formatname" bindingInformation="localhost" />
<binding protocol="https" bindingInformation="*:443:" />
</bindings>
<limits />
<logFile />
<traceFailedRequestsLogging />
<applicationDefaults />
<virtualDirectoryDefaults />
<application path="/">
<virtualDirectoryDefaults />
<virtualDirectory path="/" physicalPath="C:\inetpub\wwwroot" />
</application>
<application path="/MyWebsite" applicationPool="MyWebsite">
<virtualDirectoryDefaults />
<virtualDirectory path="/" physicalPath="D:\Projects\MySolution\DEV\Source\MyWebsite" />
</application>
</site>
</SITE>
</appcmd>
I need to make part of the virtualdirectory physicalpath D:\Projects\MySolution be whatever the currentdirectory is.
Is there any variable that I can insert in sites.xml to make that happen?

Cloud Service ReservedIP mapping error when adding a load balancer

I have below enpoints defined
<Sites>
<Site name="Internal" physicalDirectory="location">
<Bindings>
<Binding name="HttpIn100" endpointName="HttpInLB" />
<Binding name="HttpIn101" endpointName="HttpInLB" hostHeader="someheader" />
<Binding name="HttpIn102" endpointName="HttpInLB" hostHeader="someheader" />
<Binding name="HttpIn103" endpointName="HttpInLB" hostHeader="someheader" />
</Bindings>
</Site>
</Sites>
And this is the endpoint
<Endpoints>
<InputEndpoint name="HttpInLB" protocol="http" port="80" loadBalancer="LB" />
</Endpoints>
Then in my cscfg file I have
<NetworkConfiguration>
<VirtualNetworkSite name="Development" />
<AddressAssignments>
<InstanceAddress roleName="SiteName">
<Subnets>
<Subnet name="DMZ-subnet" />
</Subnets>
</InstanceAddress>
<ReservedIPs>
<ReservedIP name="ipname"/>
</ReservedIPs>
</AddressAssignments>
<LoadBalancers>
<LoadBalancer name="LB">
<FrontendIPConfiguration type="private" subnet="DMZ-subnet" staticVirtualNetworkIPAddress="00.0.00.001" />
</LoadBalancer>
</LoadBalancers>
When I publish, I get below error
ReservedIP 'ipname' was not mapped to an endpoint. The service definition must contain atleast one endpoint that maps to the ReservedIP.
Appreciate if someone could help me with this.
Many Thanks
ReservedIP is only supported with services containing an external endpoint. What you can do is add an external endpoint and block it with Network Security Groups.
For example, add following endpoint to your Endpoints tag. Then you could block the port using NSG.
<InputEndpoint name="Endpoint1" protocol="http" port="8078" />

How I define Fake Host in iis?

This Is my Host file
192.168.1.15:33693 stackoverflow.com
192.168.1.15 stackoverflow.com
first line i get nothing
second line i get iis page
i want to get my site buy it does not working
this is my applicationhost.config File
<site name="stackoverflow" id="14">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Users\stackoverflow\Desktop\stackoverflow\stackoverflow" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:33693:localhost" />
<binding protocol="http" bindingInformation="*:33693:192.168.1.15" />
</bindings>
</site>
Using the IIS manager, define a binding like so:
Equivalently, you can add the following binding statement in applicationhost.config:
<binding protocol="http" bindingInformation="*:80:stackoverflow.com" />
Additionally, 192.168.1.15 needs to be the IP of your machine. Using 127.0.0.1 is usually a better option to use in the host file in case your IP is assigned by DHCP.

DevFabric equivalent of ApplicaiontHosts.config?

I am testing OAuth with local application hosted on dev fabric.
I want to bind a particular hostname to my local application, usually on IISExpress I would edit the following element in ApplicaiontHosts.config
<site name="BasicChat" id="15">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Users\xxx.yyy_VAIO\Downloads\Samples-master\Samples-master\BasicChat" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:44914:localhost" />
</bindings>
</site>
What would be the equivalent when I'm testing on DevFabric? How can I alias the call to localhost?
In the ServiceDefinition.csdef.
Add the hostheader attribute eg:
<Site name="Web">
<Bindings>
<Binding name="Endpoint1" endpointName="xxx" hostHeader="my.yyy.com" />
</Bindings>

Azure - hostheader not accepting host without the www

I have set up my hostheader in the service definintion file as follows:
<Site name="Example" physicalDirectory="..\example.WebUx">
<Bindings>
<Binding name="Example" endpointName="HttpIn" hostHeader="www.example.com" />
</Bindings>
</Site>
When I enter www.example.com it goes to the correct web site in my role. However when I enter just example.com without the www then it goes to the default web. I tried the following and it didn't help:
<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>
I tried the following and it came up with an error message "Error 1 Found duplicate site elements defined with same virtual path 'Example/' for role 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>
I tried just the following and it didn't work. When implemented this way both the www.example.com and example.com went to the default web.
<Site name="Example" physicalDirectory="..\Example.WebUx">
<Bindings>
<Binding name="Example" endpointName="HttpIn" hostHeader="example.com" />
</Bindings>
</Site>
I'm running out of ideas :-( Does anyone have experience of setting up the hostHeader so that it can accept both the www and non-www versions of my web sites.
Thanks
Here's some links that I also checked. Unfortunately they don't seem to help
Link 1
Link 2
I don't think you will get a domain to work with the Azure DNS.
I may be a bit out of date, but I believe the way to get Azure DNS to work is through CNAME - and CNAME works on subdomains, not on domains
looks like your binding name attribute is the same.
<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>
For a top-level domain, you have to add an A record pointing to the Virtual IP of your hosted service. This is the same for all your web role instances. However, this is pretty volatile, as your VIP will change if you delete your deployment.
I have not testing top-level domains with multiple sites in a web role, so not sure if you will still run into host header issues beyond this solution. But the above will work for a web role hosting a single site.

Resources