当从node.js切换到iisnode时,有什么改变?
我一直在尝试在iisnode上运行节点应用程序。 这个应用程序运行在node.js顺利,没有问题。 但是,我需要将此应用程序集成到一个asp.net应用程序,因此我一直在尝试使用iisnode在iis上运行此应用程序! 但我一直面临一些困难! 我想知道是否有什么需要改变在config或server.js文件,使其工作?
谢谢 !
节点应用程序中唯一需要的更改将是端口号 – 在官方的/src/samples/express/hello.js中指出,在server.js / app.js中使用process.env.PORT
值而不是特定的数字(请注意最后一行):
var express = require('express'); var app = express.createServer(); app.get('/node/express/myapp/foo', function (req, res) { res.send('Hello from foo! [express sample]'); }); app.get('/node/express/myapp/bar', function (req, res) { res.send('Hello from bar! [express sample]'); }); app.listen(process.env.PORT);
还要确保asp.net的web.config有节点部分(取自/src/samples/express/web.config ):
<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>
- web.config与angular万能
- 将iisnode中的Node.js环境variables(NODE_ENV)设置为Production / Development / Test
- iis7返回404没有发现node.js网站随机错误
- 使用VB.NET在file.bat中执行gulp时没有任何反应
- 端口在IISNode上运行的Azure Node.js应用程序中未定义
- 从Node中的Active Directory获取经过身份validation的用户组
- iisnode 401消息返回iis页面
- iisnode处理请求时遇到错误。 HTTP状态:500
- 基于SSL的IIS上托pipe的NodeJS Express API返回错误:无法validation第一个证书