【发布时间】:2016-02-22 20:41:58
【问题描述】:
我正在尝试使用 iisnode 运行 express。我按照提供的示例进行操作,但是在尝试将最新的 Express 版本与基本示例一起使用时,无法使其正常工作。
我收到错误 Cannot GET /node/parislight/hello.js 和其他时候,只是 The webpage cannot be found。
我创建了一个取自the express docs 的hello.js 文件(主要快递文件)。
var express = require('express')
var app = express()
app.get('/', function (req, res) {
res.send('Hello World!')
})
var server = app.listen(process.env.PORT, function () {
var host = server.address().address
var port = server.address().port
console.log('Example app listening at http://%s:%s', host, port)
})
我添加了必要的web.config 文件(从 iisnode 中的 express 示例中提取)
<configuration>
<system.webServer>
<!-- indicates that the hello.js file is a node.js application
to be handled by the iisnode module -->
<handlers>
<add name="iisnode" path="hello.js" verb="*" modules="iisnode" />
</handlers>
<!-- use URL rewriting to redirect the entire branch of the URL namespace
to hello.js node.js application; for example, the following URLs will
all be handled by hello.js:
http://localhost/node/express/myapp/foo
http://localhost/node/express/myapp/bar
-->
<rewrite>
<rules>
<rule name="myapp">
<match url="myapp/*" />
<action type="Rewrite" url="hello.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
我为 IIS 中使用的应用程序池授予了所有必要的权限。
【问题讨论】:
标签: node.js iis express iis-8 iisnode