Table of Contents

IIS TIPs

*https://kamranicus.com/posts/2016-03-06-cors-multiple-origins-iis

Managing IIS Log files
https://www.iis.net/learn/manage/provisioning-and-managing-iis/managing-iis-log-file-storage

Note: When running above script as a Scheduled task make sure

  1. to use cscript as the command and the actually script as the argument
  2. your user has access to 'Log in as a batch Job' (set in local Security policy)
  3. the user has full control of the specific log folders
  4. the tasks should be run whether user is logged in or not. It does NOT require 'run highest privileges' It does NOT require to store password

Install DOKUWIKI on IIS

* W2012R2 - Install PHP

Reference: https://technet.microsoft.com/en-us/library/hh994592(v=ws.11).aspx\\

Summary of Install

phpinfo.php
<?php phpinfo(); ?>

Configuration of IIS

Block Access to below

	/data/
	/conf/
        /bin/
        /inc/

Enable SSL in PHP

Dynamic XML file on IIS

Powershell script to install IIS

Below is the powershell script which Cisco CCE uses to install IIS

import-module ServerManager
Install-WindowsFeature Web-Server,Web-Net-Ext45, Web-ISAPI-Ext,Web-ISAPI-Filter,Web-Request-Monitor,Web-Basic-Auth,Web-Mgmt-Console,Web-Mgmt-Compat,Web-Metabase,Web-Lgcy-Mgmt-Console,Web-Lgcy-Scripting,Web-WMI 

CORS

Example 1

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpProtocol>
            <customHeaders>
                <add name="Access-Control-Allow-Origin" value="https://*.mydomain.com" />
                <add name="Access-Control-Allow-Methods" value="GET, POST, OPTIONS, PUT, DELETE" />
                <add name="Access-Control-Allow-Headers" value="Content-Type, Authorization" />
                <add name="Access-Control-Allow-Credentials" value="true" />
            </customHeaders>
        </httpProtocol>
        <staticContent>
            <clientCache cacheControlMaxAge="00:30:00" cacheControlMode="UseMaxAge" />
        </staticContent>
    </system.webServer>
</configuration>

Example 2

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <outboundRules>
                <rule name="Set CORS for Allowed Domains" enabled="true">
                    <match serverVariable="RESPONSE_Access-Control-Allow-Origin" pattern=".*" />
                    <conditions>
                        <add input="{HTTP_ORIGIN}" pattern="^(https://([a-z0-9-]+\.)?mydomain\.com|https://example\.com)$" />
                    </conditions>
                    <action type="Rewrite" value="{HTTP_ORIGIN}" />
                </rule>
            </outboundRules>
        </rewrite>
        <httpProtocol>
            <customHeaders>
                <add name="Access-Control-Allow-Methods" value="GET, POST, OPTIONS, PUT, DELETE" />
                <add name="Access-Control-Allow-Headers" value="Content-Type, Authorization" />
                <add name="Access-Control-Allow-Credentials" value="true" />
            </customHeaders>
        </httpProtocol>
        <staticContent>
            <clientCache cacheControlMaxAge="00:30:00" cacheControlMode="UseMaxAge" />
        </staticContent>
    </system.webServer>
</configuration>

Disabled IIS Server Header

%systemroot%\system32\inetsrv\appcmd.exe set config -section:system.webServer/security/requestFiltering /removeServerHeader:true /commit:apphost  

To validate the changes, execute the below curl command, and you should not see server details as part of the header.

curl -I https://your-domain.com