Application Gateway with multiple sites hosted on each IIS/VM instance RRS feed

  • Question

  • Say for example that I have two web sites - and  Putting aside the Application Gateway for one moment, I could choose to host these as two web sites on one IIS instance - with the bindings set to send the requests to each web site in IIS.

    Until the Application Gateway comes into the mix all is fine.  But once an Application Gateway is placed in front of the VM* I get an error displayed in the browser which says:

    502 - Web server received an invalid response while acting as a gateway or proxy server.

    There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.

    I have tried adding a multi-site binding as per the instructions here:

    But it seems that whilst a host header value is specified in the binding in IIS (i.e., that the Application Gateway will return this response.  Without this host header though I don't see how I can make the traffic go to the correct web site in IIS.

    It looks to me as the request here (which is marked as completed) is asking for this functionality:

    But as per the comments (one of which I mine I should add) this doesn't seem to be working as asked.

    Many thanks


    *I will actually be deploying both web sites to two VMs in an Availability Set, as in two VMs, each with contoso and fabrikam deployed, but that is largely irrelevant to this question.

    • Edited by Paul Touzel Tuesday, November 15, 2016 10:40 AM
    Tuesday, November 15, 2016 10:27 AM

All replies

  • Hello Paul,

    Thank you for posting on the Azure forums!

    Have you looked at and tried out Application Gateway for Multi Hosting yet? This template creates an Application Gateway and configures it for Multi Hosting on port 443. You can click on Deploy To Azure button and make the necessary editing suiting your deployment.

    Let me know if this helps you.



    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer so that other customers can benefit from it.

    Tuesday, November 15, 2016 5:59 PM
  • Thanks Loydon, but that example appears to have each website on a separate backend pool/server.

    I would like a single backend pool, where each VM in that pool hosts both contoso and fabrikam.

    For example, I can see from the documentation how to do the following (and this is also similar to the example in the template you linked to):

    But I want to do this:

    Some of the reasoning behind wanting to do this is as follows:

    • I want each site to run on two VMs (to take advantage of the SLA when a VM is in an availability set)
    • At the same time there is insufficient traffic to warrant each site being on a dedicated VM - in other words each site can share the IIS instance with another site
    • So using the examples above, the design I am trying to achieve would allow me to host contoso and fabrikam across two VMs - not across four VMs
    • It's possible to host two or more web sites on a single IIS instance and set bindings accordingly - so I don't see why it shouldn't still be possible when an Application Gateway is placed in front of the IIS instance(s).

    Many thanks for your help

    Paul (I am the original poster but accidentally used a work version of a MS account for the original post and that won't let me post images)

    • Edited by Paul Touzel2 Wednesday, November 16, 2016 10:31 AM
    Wednesday, November 16, 2016 10:28 AM
  • Hello Paul,

    I set up the same environment for application gateway. Followings are the details.

    • Two web sites hosed on one IIS instance in one VM.
    • Two web sites are and
    • The web sites are added bindings in form of IP:Port:Hostname on IIS server.
    • Configure for multiple site hosting by referring to the following article.

    At first, I encounter the same problem, but after check the article about Troubleshooting bad gateway errors in Application Gateway , I found 502 errors would occur, if the default health probe is not able to reach back-end VMs.

    Therefore, I checked the settings of probes, and found that I set the parameter of Host as the private ip address of VM,  the health probe could not get the healthy HTTP response with the URL http://private-ip-address, since the IIS server hosts two web sites with binding added, it can only receive the HTTP request with the URL or

    Finally, I started the Default Web Site on the IIS, which can receive the HTTP request with URL http://private-ip-address, this make the probe connect to the VM. Eventually, it works, the web sites can be accessed normally.

    Hope this is helpful for you.

    Best Regards,
    Andy Liu

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact

    Thursday, November 17, 2016 5:48 AM
  • How can the same setup work when you have multiple SSL sites on the same backend server?

    Kyriacos Aristodemou

    Tuesday, January 30, 2018 2:35 PM
  • Hi Paul

    Did you manage to fix the issue ?

    I've trying to get App gateway work for a similar configuration and get 404



    Tuesday, February 11, 2020 10:49 AM