Score:0

Serving 2 different websites from the same IIS server on the same port

br flag

I have 2 different websites:

  • mysite.com
  • api.mysite.com

I want to be able to serve both of these websites from the same webserver (same IP) and same port number.

I have followed this document, and created the following websites:

enter image description here

This is how the binding for mysite.com looks like:

enter image description here

And this is how the binding for api.mysite.com looks like:

enter image description here

Note that the only way I could define 2 sites using the same IP and Port was to use a Host name for one of them.

With the above settings, mysite.com works but api.mysite.com does not work. If I stop mysite.com from IIS, then api.mysite.com starts working.

The document that I used as a guide explains that I need to use dnsmgmt.msc to define a CNAME for api.mysite.com, but here is where I am confused. I am using AWS and I have defined 2 CNAME records for these websites in Route 53. Do I still need to define a CNAME record for one of these websites in Windows?

If not, then how would I tell IIS that request containing api.mysite.com should be sent to website having the host name = api.mysite.com?

Update

The answer provided by Greg suggests that I would add mysite.com as Host name as well. If I follow this solution, how would I handle requests for www.mysite.com?

At the moment, any request for mysite.com is permanently redirected to www.mysite.com

Score:2
br flag

Add mysite.com to the binding for that site to match the similar configuration for api.mysite.com

My guess is that the mysite.com one is matching the request condition for api.mysite.com (just port 80).

br flag
Thanks for your answer. Do you know how should I handle `www.mysite.com`? I have updated the question.
br flag
You don’t have a www.mysite.com configuration on your server, based on your screenshots. Do you want both mysite.com and www.mysite.com to be the same site? If so, you can just add a second binding for mysite.com that has www.mysite.com as a host name.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.