In what scenarios will I use `netsh http add urlacl`?
Solution 1:
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
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 :
- Configuring HTTP and HTTPS
- Namespace Reservations, Registrations, and Routing
- HTTP.sys web server implementation in ASP.NET Core
- Demystify http.sys with HttpSysManager