If you have not already reviewed my other articles on using IIS on Nano, then you might want to take a look at them. Just so you know the perspective I am coming from and the context in which I work within.
- What’s new in IIS 10
- How to list Packages available when creating a Nano server
- How to install IIS and Tracing on a Nano for Windows Server 2016
- How to copy files or deploy code to a Nano Server
- How to connect and configure IIS running on Nano
- IIS on Nano server
- ASP.NET Core with IIS on Nano Server
- Microsoft IIS Administration on Nano Server –> important for manage.iis.net, working on that one too
I followed these instructions to setup a Nano server using Hyper-V, “Quickly deploy Nano Server in a virtual machine”. As you see in Figure 1, you need to have an ISO of Windows Server 2016 and then copy the .\NanoServer\NanaServerImageGenerator folder to a local location for running the PowerShell cmdlet discussed later and in the article I worked with, here.
Figure 1, Nano Server Image Generator
Include IIS when you build the Nano Server Image
I wanted include/install IIS so I added the “-Package Microsoft-NanoServer-IIS-Package” parameter and value to the New-NanoServerImage cmdlet. Specifically, I ran this cmdlet, also shown in Figure 2. Therefore, NOTE that the IIS package is added while the Nano Server VHD is being created. I have not tried it, but would not expect to be able to add this feature while remotely connected to the machine running the Nano server, so include it while building the VHD.
New-NanoServerImage -Edition Standard -DeploymentType Guest -MediaPath D:\ -BasePath .\Base -TargetPath .\NanoServerVm\NanoServerVM.vhd -ComputerName Nano2016IIS10 -Package Microsoft-NanoServer-IIS-Package
Figure 2, How to install IIS on Nano using Nano Server Image Generator
Configure Failed Request Tracing in IIS running Nano
At the beginning of this article I linked to another article named “How to connect and configure IIS running on Nano” here. After some looking around running these commands in PowerShell and was not able to find a way to install Failed Request tracing, I simply looked in the c:\windows\system32\inetsrv\config\applicationHost.config file and found the <tracing> section, so apparently it is installed by default.
Import-Module IISAdministration Get-Command -Module IISAdministration dism /online /get-features Get-Content .\applicationHost.config Get-IISConfigSection -SectionPath "system.webServer/tracing/traceFailedRequests" psedit c:\windows\system32\inetsrv\applicationHost.config
Then I ran this PowerShell command that configured Failed Request Tracing in IIS on Nano. The configuration will capture all the requests which result in a 500 HTTP status code.
$serverManager = Get-IISServerManager $config = $serverManager.GetWebConfiguration("/") $traceFailedRequestSection = $config.GetSection("system.webServer/tracing/traceFailedRequests") $traceFailedRequestsCollection = $traceFailedRequestSection.GetCollection() $addElement = $traceFailedRequestsCollection.CreateElement("add") $addElement["path"] = "*" $traceAreasCollection = $addElement.GetCollection("traceAreas") $addElementArea = $traceAreasCollection.CreateElement("add") $addElementArea["provider"] = "WWW Server" $addElementArea["areas"] = "Authentication,Security,WebSocket,StaticFile" $addElementArea["verbosity"] = "Verbose" $traceAreasCollection.Add($addElementArea) $failureDefinitionsElement = $addElement.GetChildElement("failureDefinitions") $failureDefinitionsElement["statusCodes"] = "500" $traceFailedRequestsCollection.Add($addElement) $serverManager.CommitChanges()
Then I enabled the Failed Request Tracing on the IIS Nano server for the give web site.
As I have not yet published a site to my IIS Nano server (there is no web.config) and enabling FREB happens at the web site level, I haven’t done this yet. But it is simply just figuring out which commands to run. I’ll come back to this at some point in the future if possible.