How to bind individual UrlPrefix to a particular network interface?

120 Views Asked by At

I am asking how to bind an UrlPrefix to a particular network interface via HTTP Server API (aka http.sys). It seems IIS somehow can do this.

iis site binding window

Netsh shows the interface IP as part of the UrlPrefix

> netsh http show servicestate view="requestq"
...
Number of registered URLs: 1
Registered URLs:
    HTTP://TEST.SITE.INVALID:80:192.168.202.142/
...                             ^^^^^^^^^^^^^^^

And it works - curl returns error when i am trying to access the site via the localhost interface

> curl.exe -vi --connect-to "test.site.invalid:80:192.168.202.142:80"  http://test.site.invalid/something.html
... 200 OK

> curl.exe -vi --connect-to "test.site.invalid:80:127.0.0.1:80"  http://test.site.invalid/something.html
... 404 Not Found

I couldn't find any mentions about such type of binding in the http server api docs. Moveover it says completely opposite

By default, once a registration is entered in the request queue, the HTTP Server API binds to the port specified in the UrlPrefix (for example port 80) for all IP addresses (INADDR_ANY or INADDR6_ANY) available on the machine.

You can add/delete a particular interface ip to the ip listen list on a whole host level but not for the individual urlprefix. Anyway the list is empty on my machine:

> netsh http show iplist

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

... nothing in the list

It is puzzling me, does IIS use some undocumented API? Anybody know?

0

There are 0 best solutions below