Perl PSGI/Plack

Installation

  1. Open Web Platform Installer and install "Perl project":
  2. Open project's home page and follow steps in "PSGI/Plack" section:
  3. Create app.pl file in the root of IIS web site with the following content:
    my $app = sub {
        return [200, ['Content-Type' => 'text/plain'], ["hello, world\n"]];
    }
    
  4. Output of sample PSGI/Plack application:

web.config example

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>

    <heliconZoo>
      <application name="perl.project" >
        <environmentVariables>

          <!-- Use this APP_WORKER with PSGI engine -->
          <add name="APP_WORKER" value="app.pl" />

          <!-- Use this APP_WORKER with Mojolicious over HTTP. Thin need to be installed. -->
          <!--
          <add name="APP_WORKER" value="mojolicious_app.pl daemon -l http://%HOST%:%PORT%" />
          -->

          <!--
          Deploy file includes the most common commands required to prepare application before launch (bundle install, migrations etc.)
          It is also possible to specify here any script which evenually will be run by rubyw.exe.
          -->
          <add name="DEPLOY_FILE" value="deploy.pl" />

          <!-- security rules for console are placed in /console/web.config -->
          <add name="CONSOLE_URL" value="console" />

        </environmentVariables>
      </application>
     </heliconZoo>

    <handlers>
      <!-- All transports below support any Psgi-based application. Uncomment the one you wish to use. -->


      <!-- Perl CGI over FastCGI -->
      <!--
      <add name="perl.project#x86" scriptProcessor="perl.5.12.pipe" path="*.pl" verb="*" modules="HeliconZoo_x86" preCondition="bitness32" resourceType="Unspecified" requireAccess="Script" />
      <add name="perl.project#x64" scriptProcessor="perl.5.12.pipe" path="*.pl" verb="*" modules="HeliconZoo_x64" preCondition="bitness64" resourceType="Unspecified" requireAccess="Script" />
       -->

      <!-- Perl over FastCGI -->
      <add name="perl.project#x86" scriptProcessor="perl.5.12.psgi" path="*" verb="*" modules="HeliconZoo_x86" preCondition="bitness32" resourceType="Unspecified" requireAccess="Script" />
      <add name="perl.project#x64" scriptProcessor="perl.5.12.psgi" path="*" verb="*" modules="HeliconZoo_x64" preCondition="bitness64" resourceType="Unspecified" requireAccess="Script" />


      <!-- Perl over HTTP  -->
      <!--
      <add name="perl.project#x86" scriptProcessor="perl.5.12.http" path="*" verb="*" modules="HeliconZoo_x86" preCondition="bitness32" resourceType="Unspecified" requireAccess="Script" />
      <add name="perl.project#x64" scriptProcessor="perl.5.12.http" path="*" verb="*" modules="HeliconZoo_x64" preCondition="bitness64" resourceType="Unspecified" requireAccess="Script" />
      -->


    </handlers>


    <!-- URL Rewrite rules to pass static files, limit console access, etc. -->
    <rewrite>
      <rules>

        <!-- This rule shows welcome page when no Rack application exist. -->
        <rule name="Rewrite to Zoo index if that's an empty application" stopProcessing="true">
          <match url="^/?$" ignoreCase="false" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="true">
            <add input="{APPL_PHYSICAL_PATH}" pattern="(.*)" ignoreCase="false" />
            <add input="{C:1}app.pl" matchType="IsFile" negate="true" />
          </conditions>

          <action type="Rewrite" url="public/zoo-index.html" />
        </rule>

      </rules>
    </rewrite>

  </system.webServer>
</configuration>

Environment variables

  • APP_WORKER — path to PSGI application’s worker script.
  • PROXYPASS — application virtual path.