"HTTP Error 400. The request hostname is invalid" When IPv4 address is used to access the siteRSS

4 replies

Last post May 14, 2020 03:50 PM by carlsonad

‹ Previous Thread|Next Thread ›
  • "HTTP Error 400. The request hostname is invalid" When IPv4 address is used to access the site

    May 13, 2020 06:55 PM|carlsonad|LINK

    When accessing a site with ARR configured to redirect to a back end service using the IPv4 address of the server I'm getting a "HTTP Error 400. The request hostname is invalid." error. 

    Accessing the ARR site from the same site using the DNS name works just fine.  I can also access the site ARR is routing traffic to directly though the IPv4 address and DNS name. 

    The ARR Site and the back end site are both on the same server (Windows Server 2019) and both are bound to any host name and any IP address as shown by executing appcmd list sites:


    SITE "Default Web Site" (id:1,bindings:http/:80:,state:Started)
    SITE "backend" (id:2,bindings:http/:30005:,state:Started)
    SITE "farmSite" (id:3,bindings:https/:30000:,state:Started)

    I took a look at the logs in C:\Windows\System32\LogFiles\HTTPERR and found the following:

    #Fields: date time c-ip c-port s-ip s-port cs-version cs-method cs-uri streamid sc-status s-siteid s-reason s-queuename
    2020-05-12 23:23:50 fe80::fd7a:8cf1:56f1:a17a%5 49719 fe80::fd7a:8cf1:56f1:a17a%5 30005 HTTP/1.1 GET /requestoutput.aspx - 400 - Hostname -

    I noticed that ARR appears to be using the IPv6 address instead of the IPv4 when communicating to the back end service.

    Once I saw that I was able to work around this by configuring windows to prefer IPv4 over IPv6 using the following link:

    https://support.microsoft.com/en-us/help/929852/guidance-for-configuring-ipv6-in-windows-for-advanced-users

    That was done by adding the following registry key:

    Location: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\
    Name: DisabledComponents
    Type: REG_DWORD

    Value: 0x20

    Why does accessing the site with IPv4 address break until Windows is configured to prefer IPv4 over IPv6?  

    Does anyone know if their are other ways to fix this?

  • Rovastar Rovastar

    5459 Posts

    MVP

    Moderator

    Re: "HTTP Error 400. The request hostname is invalid" When IPv4 address is used to access the sit...

    May 14, 2020 04:12 AM|Rovastar|LINK

    I haven't come across this but also I'm not using IPv6 in the wild yet.

    I think confusion here might be how you are communicating to your back end services.

    First off I don't recommend using ARR to route to things on the same box which it sounds like you are doing. I can't believe ARR was designed to be used this way and I struggle to understand your setup here just by having it on 1 machine as internal routing to itself can get you in tied up in knots.

    How are you routing to your "back end" service? Do you have a farm setup here? How is that configured?

    It may be that you are connecting to the server via hostname (probably looking up the DNS entry so that might be slow in itself) and that it as it is itself it will default to IPv6 to connect.

    That is a general windows thing I think not an ARR thing.

    Have a look in the apphost config for

    <webFarms>

    and you want something like this setup with the IP address of the server (maybe local host of 127.0.0.1 will work)

    <webFarm name="test farm" enabled="true">
    <server address="1.2.3.4" enabled="false">
    <applicationRequestRouting httpsPort="30005" />
    </server>
    <applicationRequestRouting>
    <healthCheck url="https://1.2.3.4:30005" statusCodeMatch="200-399" />
    </applicationRequestRouting>
    </webFarm>

    Troubleshoot IIS in style
    https://www.leansentry.com/
  • Re: "HTTP Error 400. The request hostname is invalid" When IPv4 address is used to access the sit...

    May 14, 2020 06:02 AM|Jalpa Panchal|LINK

    Hi,

    Did you restart your machine after doing a registry setting? you could try to run the below command to check IP listening:

    netsh http show iplisten

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: "HTTP Error 400. The request hostname is invalid" When IPv4 address is used to access the sit...

    May 14, 2020 02:59 PM|carlsonad|LINK

    Jalpa Panchal

    Did you restart your machine after doing a registry setting? you could try to run the below command to check IP listening:

    netsh http show iplisten

    I did restart the machine after I changed the registry setting.   After rebooting, with IPv4 preferred over IPv6 I am able to access the site using the IPv4 address where I was not able to before.  

    Regarding the http bindings, the server I am trying this on is a clean Windows 2019 Server.  I was messing with the http bindings in windows using netsh to try and resolve this problem.  Originally the output of that command was:

    IP addresses present in the IP listen list:
    -------------------------------------------

    However, I tried adding generic bindings for both IPv4 and IPv6 and the result now is:

    IP addresses present in the IP listen list:
    -------------------------------------------

    ::
    0.0.0.0

    Neither setup had an effect on the problem at hand.  Only changing windows to prefer IPv4 over IPv6.

  • Re: "HTTP Error 400. The request hostname is invalid" When IPv4 address is used to access the sit...

    May 14, 2020 03:50 PM|carlsonad|LINK

    Rovastar

    First off I don't recommend using ARR to route to things on the same box which it sounds like you are doing. I can't believe ARR was designed to be used this way and I struggle to understand your setup here just by having it on 1 machine as internal routing to itself can get you in tied up in knots.

    I can understand your recommendation about not routing to other services directly on the same machine.  I'll give you some high-level background to help you understand the solution.  But first I will say, we have worked with Microsoft on this solution and they have never said this is the wrong way to do this or it's a scenario that shouldn't work.  However, I do understand your comments/recommendation.

    I work for an ISV and part of the solutions we provide is a web based platform that is a container for other enterprise applications that the company sells.  The platform and applications have their own websites in IIS and can be flexibly deployed on the same machine as the platform or remote machines depending on the customers needs and load.  ARR is used to manifest a single endpoint to clients regardless if the various websites are installed on the same server as the Platform/ARR or on a remote server.  The platform does the work to automate the deployment of the web services and the configuration of ARR to manifest this single endpoint.  The solution also supports load-balancing these servers to provide high availability.  This allows us to support smaller customers that want a single server solution or larger customers that want a multiple server solution with high availability.  This is a solution that has worked well in the field for years now.  

    Rovastar

    How are you routing to your "back end" service? Do you have a farm setup here? How is that configured?

    It may be that you are connecting to the server via hostname (probably looking up the DNS entry so that might be slow in itself) and that it as it is itself it will default to IPv6 to connect.

    There is a farm setup.  The url rewrite rules will route requests to server farms where the target servers are registered with their DNS names and not their IP addresses.  The URL rewrite rules are defined at the farmSite level not the IIS server level.  So only requests that come into the farmSite are evaluated for url rewrite and the farmSite is never configured to reroute back to itself. 

    I can understand this isn't the common way to deploy ARR.  What I don't understand is why the farmSite (ARR) can successfully redirect traffic when it's accessed with the dns name (http://servername.domain.net:portNumber) but returns the 400 error when accessed through the IPv4 address (http://1.2.3.4:portNumber) unless IPv4 is preferred over IPv6.

‹ Previous Thread|Next Thread ›