IIS Express not handling multiple sites on one port

Ray Pooley 1 Reputation point
2023-03-30T13:33:50.0133333+00:00

The sites in question are accessed through third party DNS.

There 3 parts to the identity of a specific website as I understand it.

IP address, Port, Hostname.

If the Hostname is unique you can share the port across multiple site.

IIS Express determines whis site to return using the hostname entry in the binding.

I am using a test DNS. test.dyndns.org on port 80.

The request server variables retrieved from the request contain information about the host as follows:

HTTP_HOST:test.dyndns.org:80

Host: test.dyndns.org:80

SERVER_NAME - test.dyndns.org

HTTP_HOST - test.dyndns.org:80

I am using the SERVER_NAME value in the IIS Binding.

(It won't allow me to include the :80 information in the Host field because that has its own field)

I can't get it to work. IIS is not able to distinguish the site via the hostname.

It takes me to the IIS_DefaultSite on the same port.

My question is does anyone know what variable from the request information IIS Express uses as the hostname?

Any idea what I am missing?

Thanks

Ray

Windows development | Internet Information Services
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Ed Harris 25 Reputation points
    2023-03-30T13:50:26.75+00:00

    Hello Ray Pooley,

    Thanks for your question! You understand that websites are bound to an IP address and port given their hostname.

    By default, IIS sets up a default site running on port 80. As a result, you may get errors or warnings when trying to map other sites to this port because port 80 is currently in use and IIS would need to be restarted to realize the changes.

    Please try stopping the default IIS website. You may even remove it completely. Then you should be able to add the entries as you desire using the command line or GUI.

    Please reference https://woshub.com/run-multiple-websites-on-the-same-port-and-ip-address-on-iis/ for more information and a more hands-on walkthru complete with command line and PowerShell commands. Please let me know if there is anything else I can help you with!

    I seem to have overlooked your main question. IIS views the HTTP request header for this information. Please refer to https://developer.mozilla.org/en-US/docs/web/http/headers#request_context for more information on HTTP headers, specifically the host.

    0 comments No comments

  2. Yurong Dai-MSFT 2,846 Reputation points Microsoft External Staff
    2023-03-31T05:34:08.77+00:00

    Hi @Ray Pooley,

    In IIS Express, the variable used as the host name in the request information is "Host", which contains the target host name or IP address of the HTTP request. If the "Host" variable is included in the received request header, IIS Express will use it to determine the site that should process the request; if the "Host" variable is not included in the request header, it will use localhost as the host name by default and route the request to the default site for IIS Express.

    Try accessing the site with a different browser or clearing your current browser's cache and cookies to make sure this is not a caching issue.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the email notification for this thread.

    Best regards,

    Yurong Dai


  3. Lex Li 6,037 Reputation points
    2023-03-31T14:50:50.59+00:00

    If I were you I would use a tool like Wireshark to analyze the HTTP requests generated by that "dynamic DNS" further. test.dyndns.org:80 as Host header is technically correct, but never the convention. Contact the vendor and ask them to correct such misbehaviors.

    In case they cannot change that for whatever reason, your next move is not to change IIS side site bindings, as test.dyndns.org:80 is not a valid value to use there. Alternatively, use the Default Web Site who accepts all kinds of Host headers as your starting point and add reverse proxy rules to forward the requests to the right sites.

    I wrote about a similar case which might give you some hints.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.