如何在web.config中的处理程序标记中指定文件路径

问题描述 投票:0回答:1

我试图在Azure云上运行一个简单的node.js应用程序。

我基本上遵循了以下网站上的说明。

- Web应用程序的创建 - https://code.visualstudio.com/tutorials/app-service-extension/create-app

- 部署Web应用程序 - https://code.visualstudio.com/tutorials/app-service-extension/deploy-app

为了在Azure(IIS)上运行它,我在根文件夹中添加了web.config和server.js,如下所示。 added 2 files

文件内容如下。 [web.config中]

<configuration>
<system.webServer>
      <handlers>

        <!-- Indicates that the server.js file is a node.js site to be handled by the iisnode module -->
        <add name="iisnode" path="server.js" verb="*" modules="iisnode"/>
      </handlers>
      <rewrite>
        <rules>

          <!-- All URLs are mapped to the node.js site entry point -->          
          <rule name="DynamicContent">
            <match url="/*" />
            <action type="Rewrite" url="server.js"/>
          </rule>

        </rules>
      </rewrite>
</system.webServer>
</configuration> 

[server.js]以下仅显示部分代码。

#!/usr/bin/env node

/**
 * Module dependencies.
 */

var app = require('./app');
var debug = require('debug')('myexpressapp:server');
var http = require('http');

/**
 * Get port from environment and store in Express.
 */

var port = normalizePort(process.env.PORT || '3000');
app.set('port', port);

/**
 * Create HTTP server.
 */

部署到Azure(IIS)后,Web应用程序成功运行。但是,我想使用bin / www文件而不是server.js。实际上,我通过复制bin / www文件在根文件夹中创建了server.js文件。为了直接使用bin / www,我按如下方式更改了web.config,但这会导致错误。浏览器显示错误;“您要查找的资源已被删除,其名称已更改,或暂时不可用。”似乎找不到www文件。我怎么写错路径?

<configuration>
<system.webServer>
      <handlers>

        <!-- Indicates that the server.js file is a node.js site to be handled by the iisnode module -->
        <add name="iisnode" path="bin/www" verb="*" modules="iisnode"/>
      </handlers>
      <rewrite>
        <rules>

          <!-- All URLs are mapped to the node.js site entry point -->          
          <rule name="DynamicContent">
            <match url="/*" />
            <action type="Rewrite" url="bin/www"/>
          </rule>

        </rules>
      </rewrite>
</system.webServer>
</configuration> 

我将不胜感激任何帮助。

node.js azure iis path web-config
1个回答
0
投票

我能够解决问题。我将文件夹的名称从“bin”更改为其他名称,并且它有效。我试图理解为什么名称“bin”不起作用...是因为“bin”是由服务器保留的,它不能被使用?如果有人能让我知道任何可能的原因,我会赞美它...

© www.soinside.com 2019 - 2024. All rights reserved.