# IIS (Internet Information Services)

Deploying directus to IIS will require iisnode (opens new window), the IIS URL Rewrite module, an entrypoint file, and some specific web.config configurations.

# iisnode

iisnode can be downloaded from the azure/iisnode releases (opens new window) page.

# IIS URL Rewrite module

The URL Rewrite module can be downloaded from the Microsoft IIS website (opens new window).

# Entrypoint

iisnode acts as a reverse proxy, and simply forwards requests to files based on any rewrite rules and the files available. Since iisnode simply pipes requests to files, running the directus CLI directly won't work. To get around this, use an entrypoint script like the index.js below.

var { startServer } = require('directus/server');


# web.config

With an entrypoint created, add a web.config to the root of the project. The following web.config is a simple example of running directus with iisnode

<?xml version="1.0" encoding="utf-8"?>
  <location path="." inheritInChildApplications="false">
        <add name="iisnode" path="index.js" verb="*" modules="iisnode" />
      <iisnode node_env="%node_env%" loggingEnabled="true" enableXFF="true" />
          <rule name="root">
            <match url="(.*)" />
            <action type="Rewrite" url="index.js" />
      <httpErrors existingResponse="PassThrough" />

A few important points regarding this file:

  1. The iisnode handler path parameter is set to the entrypoint filepath
  2. The iisnode handler verb parameter is set to handle all verbs (*)
  3. The iisnode node_env parameter is bound to the environment variable node_env
  4. The iisnode enableXFF parameter is set to true. Since iisnode acts as a reverse proxy, this is required to pass client IP and other details on to the directus server, which directus modules expect and depend on.
  5. The rewrite rule is in place to send all requests made to this site to the entrypoint, ensuring that directus handles the routing and not IIS
  6. The error page response needs to be untouched by IIS for two-factor authentication to work.

While there are dozens even hundreds of options within IIS, this should help in getting started with Directus on IIS.