Run Dream under IIS 7

MindTouch Dream contains a System.Web.HttpHandler class to process requests and send them into the Dream environment without the need for running an external executable such as mindtouch.host.exe.  Below are the steps for configuring Dream for IIS7.

Instructions

  1. Create the folder structure depicted below
    1. Copy the web.config file into the dream folder
    2. Copy the dream.startup.xml into the dream folder
    3. Copy the Dream binaries into dream/bin folder
    4. Copy explicitly registered Dream service binaries into the dream/bin folder
    5. Copy self-registering Dream service binaries into the dream/bin/services
  2. Grant to the IIS_IUSRS account read-write access to the dream/data tree
  3. Follow these IIS configuration steps:
    1. Click on Start » Adminstrative Tools » Internet Information Services (IIS) Manager
    2. Click on Connect to localhost
    3. Right-click on Sites
    4. Select Add Web Site...
    5. Enter site name (e.g. Dream)
    6. Set physical path to the dream folder
    7. Click Ok
  4. Open a browser and go to http://localhost/host/version to verify that Dream works

Folder Structure

--- dream
    |
    |-- bin
    |   |
    |   \-- services
    |
    \-- data
        |
        |-- logs
        |
        \-- servicestate

Sample web.config file

Configure the Dream Settings section for your application.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  
  <!-- NOTE: this element must be first -->
  <configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
  </configSections>

  <!-- add 'bin/services' folder to assembly search path -->
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="bin;bin\services"/>
    </assemblyBinding>
  </runtime>

  <!-- Dream Settings -->
  <appSettings>
    <!-- Lucene lock directory; if not specified, the system temp dir will be used. -->
    <add key="Lucene.Net.lockDir" value="..\data\lock"/>
    
    <!-- Folder where service state is stored -->
    <add key="storage-dir" value="..\data\servicestate" />
    
    <!-- TODO: set the Dream host service API key -->
    <add key="apikey" value="123" />

    <!-- Script(s) to run when Dream server starts up -->
    <add key="script" value="dream.startup.xml" />
  </appSettings>

  <!-- IIS connection settings -->
  <system.net>
    <connectionManagement>
      <clear />
      <add address="*" maxconnection="16" />
    </connectionManagement>
  </system.net>

  <!-- IIS 7 handler settings -->
  <system.webServer>
    <security>
      <requestFiltering allowDoubleEscaping="true" />
    </security>
    <handlers>
      <clear />
      <add name="Dream" path="*" verb="*" type="MindTouch.Dream.Http.HttpHandler, mindtouch.core" resourceType="Unspecified" preCondition="integratedMode" />
    </handlers>
    <httpProtocol>
      <customHeaders>
        <remove name="X-Powered-By" />
      </customHeaders>
    </httpProtocol>
  </system.webServer>

  <!-- Log4Net settings -->
  <log4net>
    <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender, log4net">
      <file value="..\data\logs\dream.log" />
      <appendToFile value="true" />
      <maximumFileSize value="100KB" />
      <maxSizeRollBackups value="4" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
      </layout>
    </appender>
    <appender name="OutputDebugStringAppender" type="log4net.Appender.TraceAppender">
      <layout type="log4net.Layout.PatternLayout">
        <param name="ConversionPattern" value="%date [%thread] %-5level %logger - %message%newline" />
      </layout>
    </appender>
    <root>
      
      <!-- Set logging level to ALL, FATAL, ERROR, WARN, INFO, or DEBUG -->
      <level value="DEBUG" />
      <appender-ref ref="RollingFileAppender" />
      <appender-ref ref="OutputDebugStringAppender" />
    </root>
  </log4net>
</configuration>

Sample dream.startup.xml file

<script>

  <!-- TODO: repeat the following line for each assembly that needs to be explicitly loaded -->
  <action verb="POST" path="/host/load?name=service-assembly" />

  <!-- TODO: repeat for each service that needs to be started -->
  <action verb="POST" path="/host/services">
    <config>
      <path>service-path</path>
      <sid>sid://example.com/service-name</sid>
      <!-- TODO: add custom <config> elements -->
    </config>
  </action>
</script>

Troubleshooting

If you receive "400 Bad Request" errors due to an invalid character in the path (such as :, & or %), you need to make a change to the registry to allow these characters.

 

Tag page
You must login to post a comment.