27

I'm trying to understand in which scenarious I will need to use such command :

netsh http add urlacl url=http://server1:1234/ user=Everyone

Is it like using the hosts file where I can connect a specific address to my computer ? (I don't think so).

The docs are not that clear ( to me) :

Netsh is a command-line scripting utility that allows you to, either locally or remotely, display or modify the network configuration of a computer that is currently running. Netsh also provides a scripting feature that allows you to run a group of commands in batch mode against a specified computer. Netsh can also save a configuration script in a text file for archival purposes or to help you configure other servers.

Question:

Can someone please supply a real life scenario (+ implementation) where I will want to use it ?

Additional Info : I've read this question where a guy who've tried to access ( via C#) to :

http://localhost:1234 works, but

http://server1:1234 fails

(However - I don't understand why didn't he use the hosts file which could solve it ) - But then another person has answered that netsh will do the job.
So I guess I'm missing something here.

1
  • I perfectly know what hosts file is used for i do it every day for the last 1 years. I dont understand how the code in my question is differ from hosts file. It seems that they both do the same. And sadly , you didnt supply any difference in your answer
    – Royi Namir
    Dec 1, 2017 at 17:38

1 Answer 1

29
+50

You would use netsh http when modifying the configuration of http.sys, which is totally different from the hosts file, working on a much lower level of Windows. This level is the one that handles the running of an HTTP server locally in your computer, so is concerned with requests coming into your computer, rather than the ones going out to the Internet.

This is the architecture in Windows for serving URL requests :

http.sys architecture

http.sys is the driver that listens to HTTP traffic and dispatches requests based on the URL to processes, so multiple processes can listen to HTTP traffic on the same port.

http.sys was introduced in Windows server 2003. Before, applications just opened a socket on an endpoint (IP:Port), listening to incoming traffic and parsing it. The problem was that this made it impossible for all the applications to use port 80 (http) and 443 (https), as with the socket model only one application can listen to an endpoint at any given time.

When the Internet Information Services (IIS) Web server, or any application that uses the HTTP Server API, listen on some HTTP request path, they need to register a URL prefix on http.sys. We call this process registration.

When an incoming request is picked by http.sys and it is delivered to the the right registered application, this is called routing.

Any application running in administrator mode can register for a URL. A non-administrator application needs to use netsh http add urlacl to receive the request.

Conclusion: Since you are not building a low-level URL server running in non-administrator mode, you have no reason to use netsh http add urlacl.

References :

2
  • Can you please provide a scenario where something like:" a user wants to connect to your iis with...."
    – Royi Namir
    Dec 2, 2017 at 17:04
  • This is a method for applications to work side-by-side with IIS. If it registers for a URL prefix, the application will get all its requests directly and not through IIS, meaning it needs not be written as an extension of IIS, nor do you even need to install IIS (this is in theory - I don't know how well in practice http.sys is independent from IIS).
    – harrymc
    Dec 2, 2017 at 17:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .