import{r as t,p as r,q as i,w as o,z as e,R as s}from"./vendor.8ed37afc.js";const c=e("div",{class:"markdown-body"},[e("p",null,[s("Deploying directus to IIS will require "),e("a",{href:"https://github.com/Azure/iisnode",target:"_blank",rel:"noopener noreferrer"},"iisnode"),s(", the IIS URL Rewrite module, an entrypoint file, and some specific web.config configurations.")]),e("h2",{id:"iisnode"},[s("iisnode "),e("a",{class:"header-anchor",href:"#iisnode"},"#")]),e("p",null,[s("iisnode can be downloaded from the "),e("a",{href:"https://github.com/Azure/iisnode/releases",target:"_blank",rel:"noopener noreferrer"},"azure/iisnode releases"),s(" page.")]),e("h2",{id:"iis-url-rewrite-module"},[s("IIS URL Rewrite module "),e("a",{class:"header-anchor",href:"#iis-url-rewrite-module"},"#")]),e("p",null,[s("The URL Rewrite module can be downloaded from the "),e("a",{href:"https://www.iis.net/downloads/microsoft/url-rewrite",target:"_blank",rel:"noopener noreferrer"},"Microsoft IIS website"),s(".")]),e("h2",{id:"entrypoint"},[s("Entrypoint "),e("a",{class:"header-anchor",href:"#entrypoint"},"#")]),e("p",null,[s("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\u2019t work. To get around this, use an entrypoint script like the "),e("code",null,"index.js"),s(" below.")]),e("pre",null,[e("code",{class:"language-js"},[e("span",{class:"hljs-keyword"},"var"),s(" { startServer } = "),e("span",{class:"hljs-built_in"},"require"),s("("),e("span",{class:"hljs-string"},"'directus/server'"),s(`);

startServer();
`)])]),e("h2",{id:"web.config"},[s("web.config "),e("a",{class:"header-anchor",href:"#web.config"},"#")]),e("p",null,"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"),e("pre",null,[e("code",{class:"language-xml"},[e("span",{class:"hljs-meta"},'<?xml version="1.0" encoding="utf-8"?>'),s(`
`),e("span",{class:"hljs-tag"},[s("<"),e("span",{class:"hljs-name"},"configuration"),s(">")]),s(`
  `),e("span",{class:"hljs-tag"},[s("<"),e("span",{class:"hljs-name"},"location"),s(),e("span",{class:"hljs-attr"},"path"),s("="),e("span",{class:"hljs-string"},'"."'),s(),e("span",{class:"hljs-attr"},"inheritInChildApplications"),s("="),e("span",{class:"hljs-string"},'"false"'),s(">")]),s(`
    `),e("span",{class:"hljs-tag"},[s("<"),e("span",{class:"hljs-name"},"system.webServer"),s(">")]),s(`
      `),e("span",{class:"hljs-tag"},[s("<"),e("span",{class:"hljs-name"},"handlers"),s(">")]),s(`
        `),e("span",{class:"hljs-tag"},[s("<"),e("span",{class:"hljs-name"},"add"),s(),e("span",{class:"hljs-attr"},"name"),s("="),e("span",{class:"hljs-string"},'"iisnode"'),s(),e("span",{class:"hljs-attr"},"path"),s("="),e("span",{class:"hljs-string"},'"index.js"'),s(),e("span",{class:"hljs-attr"},"verb"),s("="),e("span",{class:"hljs-string"},'"*"'),s(),e("span",{class:"hljs-attr"},"modules"),s("="),e("span",{class:"hljs-string"},'"iisnode"'),s(" />")]),s(`
      `),e("span",{class:"hljs-tag"},[s("</"),e("span",{class:"hljs-name"},"handlers"),s(">")]),s(`
      `),e("span",{class:"hljs-tag"},[s("<"),e("span",{class:"hljs-name"},"iisnode"),s(),e("span",{class:"hljs-attr"},"node_env"),s("="),e("span",{class:"hljs-string"},'"%node_env%"'),s(),e("span",{class:"hljs-attr"},"loggingEnabled"),s("="),e("span",{class:"hljs-string"},'"true"'),s(),e("span",{class:"hljs-attr"},"enableXFF"),s("="),e("span",{class:"hljs-string"},'"true"'),s(" />")]),s(`
      `),e("span",{class:"hljs-tag"},[s("<"),e("span",{class:"hljs-name"},"rewrite"),s(">")]),s(`
        `),e("span",{class:"hljs-tag"},[s("<"),e("span",{class:"hljs-name"},"rules"),s(">")]),s(`
          `),e("span",{class:"hljs-tag"},[s("<"),e("span",{class:"hljs-name"},"rule"),s(),e("span",{class:"hljs-attr"},"name"),s("="),e("span",{class:"hljs-string"},'"root"'),s(">")]),s(`
            `),e("span",{class:"hljs-tag"},[s("<"),e("span",{class:"hljs-name"},"match"),s(),e("span",{class:"hljs-attr"},"url"),s("="),e("span",{class:"hljs-string"},'"(.*)"'),s(" />")]),s(`
            `),e("span",{class:"hljs-tag"},[s("<"),e("span",{class:"hljs-name"},"action"),s(),e("span",{class:"hljs-attr"},"type"),s("="),e("span",{class:"hljs-string"},'"Rewrite"'),s(),e("span",{class:"hljs-attr"},"url"),s("="),e("span",{class:"hljs-string"},'"index.js"'),s(" />")]),s(`
          `),e("span",{class:"hljs-tag"},[s("</"),e("span",{class:"hljs-name"},"rule"),s(">")]),s(`
        `),e("span",{class:"hljs-tag"},[s("</"),e("span",{class:"hljs-name"},"rules"),s(">")]),s(`
      `),e("span",{class:"hljs-tag"},[s("</"),e("span",{class:"hljs-name"},"rewrite"),s(">")]),s(`
      `),e("span",{class:"hljs-tag"},[s("<"),e("span",{class:"hljs-name"},"httpErrors"),s(),e("span",{class:"hljs-attr"},"existingResponse"),s("="),e("span",{class:"hljs-string"},'"PassThrough"'),s(" />")]),s(`
    `),e("span",{class:"hljs-tag"},[s("</"),e("span",{class:"hljs-name"},"system.webServer"),s(">")]),s(`
  `),e("span",{class:"hljs-tag"},[s("</"),e("span",{class:"hljs-name"},"location"),s(">")]),s(`
`),e("span",{class:"hljs-tag"},[s("</"),e("span",{class:"hljs-name"},"configuration"),s(">")]),s(`
`)])]),e("p",null,"A few important points regarding this file:"),e("ol",null,[e("li",null,[s("The iisnode handler "),e("code",null,"path"),s(" parameter is set to the entrypoint filepath")]),e("li",null,[s("The iisnode handler "),e("code",null,"verb"),s(" parameter is set to handle all verbs (*)")]),e("li",null,[s("The iisnode "),e("code",null,"node_env"),s(" parameter is bound to the environment variable "),e("code",null,"node_env")]),e("li",null,[s("The iisnode "),e("code",null,"enableXFF"),s(" parameter is set to "),e("code",null,"true"),s(". 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.")]),e("li",null,"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"),e("li",null,"The error page response needs to be untouched by IIS for two-factor authentication to work.")]),e("p",null,"While there are dozens even hundreds of options within IIS, this should help in getting started with Directus on IIS.")],-1),j={setup(h,{expose:n}){const a={title:"IIS (Internet Information Services)",modularExtension:!1};return n({frontmatter:a}),(p,d)=>{const l=t("DocsWrapper");return r(),i(l,{frontmatter:a},{default:o(()=>[c]),_:1})}}};export{j as default};
