Catalog / IIS Cheat Sheet

IIS Cheat Sheet

A comprehensive cheat sheet for Internet Information Services (IIS), covering essential configuration, management, and troubleshooting techniques.

Core IIS Concepts

Key Components

Application Pools

Isolate web applications for better security and reliability. Each pool runs in its own worker process.

Web Sites

Host websites with unique bindings (IP address, port, hostname).

Virtual Directories

Map physical directories to URL paths within a website.

Handlers

Process specific file types (e.g., .aspx, .php).

Modules

Extend IIS functionality (e.g., authentication, logging).

Bindings

Associate a website with an IP address, port, and hostname. Supports HTTP and HTTPS.

IIS Architecture Overview

IIS architecture consists of the following layers:

  • User Interface Layer: GUI tools like IIS Manager.
  • Configuration System: Stores IIS settings in XML files (applicationHost.config).
  • Web Administration Service (WAS): Manages application pool configuration and lifecycle.
  • HTTP.sys: Kernel-mode listener that receives HTTP requests.

Important Configuration Files

applicationHost.config

Main configuration file located in %windir%\System32\inetsrv\config\.

web.config

Application-specific configuration file, placed in the root directory of a web application.

machine.config

Framework-level configuration, typically located in %windir%\Microsoft.NET\Framework[64]\<version>\config\.

Management and Configuration

IIS Manager

The IIS Manager is a GUI tool for managing IIS. Common tasks include:

  • Creating and managing websites and application pools.
  • Configuring bindings, handlers, and modules.
  • Setting authentication and authorization rules.
  • Monitoring server performance and health.

PowerShell Cmdlets

Get-Website

Lists all websites.

New-Website -Name "MyNewSite" -PhysicalPath "C:\MyNewSite" -BindingInformation ":80:www.example.com"

Creates a new website.

Stop-Website -Name "MyNewSite"

Stops a website.

Get-WebAppPoolState

Gets the state of all application pools.

Restart-WebAppPool -Name "MyAppPool"

Restarts an application pool.

Import-Module WebAdministration

Import the WebAdministration module to use IIS-specific cmdlets.

Command-Line Tools

appcmd list sites

Lists all websites.

appcmd add site /name:"MyNewSite" /physicalPath:"C:\MyNewSite" /bindings:http/*:80:www.example.com

Creates a new website.

appcmd stop site "MyNewSite"

Stops a website.

appcmd list apppools

Lists all application pools.

appcmd recycle apppool "MyAppPool"

Recycles an application pool.

Security and Authentication

Authentication Methods

Anonymous Authentication

Allows access to the website without requiring users to provide credentials. Uses the IUSR account by default.

Basic Authentication

Sends usernames and passwords in plain text (Base64 encoded). Should only be used over HTTPS.

Windows Authentication

Uses Windows credentials (NTLM or Kerberos) for authentication.

Forms Authentication

Uses a custom login form and stores authentication information in cookies or sessions.

ASP.NET Impersonation

Allows the application to run under the identity of the authenticated user.

SSL/TLS Configuration

To configure SSL/TLS:

  1. Obtain an SSL certificate from a Certificate Authority (CA).
  2. Install the certificate in the server’s certificate store.
  3. Add an HTTPS binding to the website (port 443).
  4. Select the installed certificate for the binding.
  5. Enforce HTTPS by requiring SSL in IIS settings.

Authorization Rules

Allow Rules

Grant access to specific users, groups, or IP addresses.

Deny Rules

Restrict access to specific users, groups, or IP addresses.

URL Authorization

Configure authorization rules for specific URLs or directories within a website.

Troubleshooting

Common Error Codes

401.1

Authentication failed due to invalid credentials.

403.14

Directory browsing is disabled. Enable it or specify a default document.

404

Resource not found. Check the URL and physical path.

500

Internal server error. Check the application event logs for details.

503

Service unavailable. The application pool may be stopped or overloaded.

Logging and Monitoring

IIS logs detailed information about requests, errors, and performance. Check the following logs:

  • IIS logs: Located in %SystemDrive%\inetpub\logs\LogFiles.
  • Application event logs: Use Event Viewer to view application errors.
  • HTTP.sys logs: Located in %SystemRoot%\System32\LogFiles\HTTPERR.

Troubleshooting Steps

  1. Check the application pool status: Ensure the application pool is running.
  2. Verify the physical path: Make sure the physical path in IIS points to the correct directory.
  3. Test the website bindings: Confirm that the website is bound to the correct IP address, port, and hostname.
  4. Review the web.config file: Look for syntax errors or incorrect settings.
  5. Examine the application event logs: Check for application errors or exceptions.
  6. Use Failed Request Tracing: Capture detailed information about failed requests.