Port this doc from Katana: http://katanaproject.codeplex.com/wikipage?title=Selfhosting
Here's a description of WebListener that can also be added to the doc: https://github.com/aspnet/ServerTests/issues/42
The blog post by Neel Bhatt is well done, here's a proposed outline for the new doc that follows a similar organization and expands on it:
@danroth27 the Katana content that we're porting to Docs refers to third-party tools that are unsupported but are easier to work with than netsh command line, also links to third-party blogs. Is it OK to retain this info when we port the content?
@tdykstra I think that's fine
Here are my step-by-step notes for running a WebListener console server on Windows Server Core 2016. This was done with a VM, but could be used in a Docker for Windows container environment.
PowerShell to create a self-signed cert
New-SelfSignedCertificate -CertStoreLocation Cert:\LocalMachine\My -DnsName server0.contoso.com
Cert created with the thumbprint: C74235968895ECA9C9D50703D30CE17A7D3AEEFF
PowerShell to create a GUID to use as AppId
New-guid
Guid created: 921328e8-5cdf-4b7f-a3cc-4e50147d1521
Standard cmd Prompt commands to create the Url ACLs (80 and 443)
netsh http add urlacl url=https://+:443/ user=Users
netsh http add urlacl url=http://+:80/ user=Users
Standard cmd Prompt command to associate the cert thumb print and App Id (created above) with port 443
netsh http add sslcert ipport=0.0.0.0:443 certhash=C74235968895ECA9C9D50703D30CE17A7D3AEEFF appid={921328e8-5cdf-4b7f-a3cc-4e50147d1521}
Note: If you run the above from PowerShell rather than cmd, you may need to escape some characters to get it to work
PowerShell to Download .Net Core to the machine
Invoke-WebRequest "https://go.microsoft.com/fwlink/?LinkID=827524" -OutFile .\DotNetCoreSetup.exe -UseBasicParsing
Install .Net Core from the cmd line
.\DotNetCoreSetup.exe /install /quiet /log .\log.txt
PowerShell to Restart the computer after the install
Restart-Computer
Note: You don't need to restart, but it is a pain if you don't let the machine pick up the environment changes
PowerShell to Open the Firewall Ports and Allow Traffic to WebListener
New-NetFirewallRule -DisplayName 'HTTP(S) Inbound' -Profile @('Domain', 'Private') -Direction Inbound -Action Allow -Protocol TCP -LocalPort @('80', '443')
Copy and Run Your App on the Machine
Create a directory for your application
Copy your application into it
Type 'dotnet restore' from the cmd line
Type 'dotnet run' from the cmd line
Final Note
Make sure the .UseUrls("http://+:80", "https://+:443") call matches the URL ACLs you created with netsh earlier.
If this is not done, you may receive a 503 Service Unavailable from the web server.
Wrote a post on it here: https://blogs.msdn.microsoft.com/timomta/2016/11/04/how-do-i-set-up-a-net-core-weblistener-with-ssl/
Url configuration: https://msdn.microsoft.com/en-us/library/windows/desktop/aa364698(v=vs.85).aspx
Thanks for the blog post @timomta !
Most helpful comment
The blog post by Neel Bhatt is well done, here's a proposed outline for the new doc that follows a similar organization and expands on it:
What is WebListener
When to use it
How to use it in ASP.NET Core apps
How to use outside of ASP.NET Core