我正在使用iisnode在Windows上的IIS中托管节点Web应用程序.当我在Web服务器上设置我的路由(比如Express或Restify)时,我希望以一种独立于IIS托管应用程序的路径的方式进行.
例如,我的应用程序可以在运行IIS的两台计算机上的两个不同路径上托管; 第一个可以/foo在第二个主持它/bar.假设我的应用程序想要/baz在第一台机器上设置路由,我需要在第二台机器上配置路由,/foo/baz在第二台机器上我必须使用/bar/baz这意味着复制IIS中保存的一些配置.
是否可以从使用iisnode托管的应用程序中可靠地计算出路径,以便我可以计算出要设置的正确路由?或者是否有其他技术可以避免需要这样做?
我正在使用IIS7上托管的nodejs + expressjs做原型.我试图在app.js中的web.config中访问appSettings以下示例:
不幸的是,上面帖子中的样本记录为"未定义"而不是值"test".是否还需要在web.congig或app.js中设置其他任何内容才能访问web.config值?
我正在使用visual studio 2013来运行/调试项目,并且没有问题可以运行它.谢谢
我确定这个问题已被问了一百万次,但我还没有找到解决以下问题的方法.
我有一个使用nodejs和express运行的基本应用程序.当我在节点中运行应用程序时,它默认将我发送到我公共文件夹中的index.html.即使我没有设置任何路线.我希望这发生.
我安装了iisnode并在'Default Website'下创建了一个名为'Devices'的新应用程序.我把我的申请保持不变.阅读我需要用web.config排序一些东西,并决定使用这里提到的配置(而不是yaml):
http://tomasz.janczuk.org/2012/05/yaml-configuration-support-in-iisnode.html
当我尝试在浏览器中加载应用程序时,它总是尝试在我的app.js中找到路径并向我发送消息,例如:
无法获取/设备/
我真的用这个把头发拉出来,不知道该怎么办!我是否必须在app.js入口点内为静态内容设置默认路由?我有以下内容:
app.configure(function(){
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
});
Run Code Online (Sandbox Code Playgroud)
但是当我从它的根加载应用程序时,它仍然没有把我交给index.html:
的 'http://本地主机/设备/'
有人能帮我解决这个问题吗?
我也在iisnode github项目上问过
我正在通过Windows Azure网站使用IISNode。
如果我的Node应用返回2xx状态码(200、201等),则一切正常,并且可以按预期工作。
如果我的Node应用返回一个4xx状态代码,例如:(
response.send(404, "not found")我正在使用Restify),则会收到500发送给客户端的消息,正文为“由于发生内部服务器错误,无法显示该页面”。
如果我这样做azure site log tail <sitename>,则当500发送到客户端时,日志中包含404的HTML。
...
<body>
<div id="content">
<div class="content-container">
<h3>HTTP Error 404.0 - Not Found</h3>
<h4>The resource you are looking for has been removed, had its name changed,
or is temporarily unavailable.</h4>
</div>
...
Run Code Online (Sandbox Code Playgroud)
我真的只希望IISNode / IIS接收我的404并将其发送给客户端。401、409等也是如此。它们全都导致发送500。
我试过了<customErrors mode="off" />,<httpErrors existingResponse="passThrough" />在我的web.config中没有任何作用。现在是我的web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<customErrors mode="off" />
</system.web>
<system.webServer>
<httpErrors existingResponse="PassThrough" />
<staticContent>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" /> …Run Code Online (Sandbox Code Playgroud) 我知道我可以使用web.config.
<iisnode
node_env="production"
/>
Run Code Online (Sandbox Code Playgroud)
指定一个node_env可以在服务器端*.js文件中访问的环境变量process.env.node_env.
但是,例如我想访问另一个环境变量,如
process.env.GLOBAL_PREFIX.类似的方案,例如访问AWS凭据.
当我尝试
<iisnode
node_env="production"
GLOBAL_PREFIX="somevalue"
/>
Run Code Online (Sandbox Code Playgroud)
,由于无法识别的web.config文件,我无法运行应用程序.
我已按照此github页面上提到的步骤进行操作。但即使在完成上述所有操作之后,在尝试运行由 issnode 包附带的 setupsamples.bat 文件安装的示例应用程序时,我仍然不断收到内部服务器错误。
我已附上屏幕截图和相关代码文件。
这是 hello.js 文件
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('Hello, world! [helloworld sample; iisnode version is ' + process.env.IISNODE_VERSION + ', node version is ' + process.version + ']');
}).listen(process.env.PORT);
Run Code Online (Sandbox Code Playgroud)
和 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>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud) 我正在使用iisnode作为处理程序运行express.js应用程序。
每当我在IIS中重新启动站点或回收应用程序池(手动或通过更改文件后保存Web配置)时,应用程序都会崩溃,并显示500.1001错误,但仅在第一次请求时出现。如果此后请求相同的路线或任何其他路线,则该应用程序可以正常运行。
我在index.js入口点中有此代码
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);
});
Run Code Online (Sandbox Code Playgroud)
在第一个请求上为主机,端口记录了未定义的日志,但是我不知道为什么!
详细错误信息:
我的网站在快递中工作.但现在我需要在IIS上托管它.如何让我的路由与IISNode一起使用?
我能够将我的静态内容移动到/ public文件夹(html,前端js等).我不想这样做,但让那部分工作.
我将服务器端逻辑移到了/ server.
我以前有.Net Web API样式路由工作,我的服务托管在/ api.我将这些移动到/ server/api.
每当我尝试请求我的API时,我都会获得404.如何使用IISNode?
app.use("/api", require("./api"));
// routes/api/index.js
var router = require('express').Router();
router.use('/questionsets', require('./questionsets'));
module.exports = router;
var router = require('express').Router();
router.use('/questionsets', require('./questionsets.js'));
module.exports = router;
// routes/api/questions.js
var router = require('express').Router();
router.get('/', function (req, res) {
...
});
router.get('/:id', function (req, res) {
...
});
module.exports = router;
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<security>
<requestFiltering>
<hiddenSegments>
<remove segment="bin" />
</hiddenSegments>
</requestFiltering>
</security>
<handlers>
<add name="iisnode" path="bin/www" verb="*" modules="iisnode" />
</handlers>
<iisnode loggingEnabled="false" …Run Code Online (Sandbox Code Playgroud) 我正在使用 iisnode 在 Windows 服务器上运行 Node 项目,并得到以下 iisnode 输出
(节点:9616)[DEP0005] DeprecationWarning:由于安全和可用性问题,Buffer() 已被弃用。请改用 Buffer.alloc()、Buffer.allocUnsafe() 或 Buffer.from() 方法。
我理解该消息的含义,但我没有Buffer()在任何代码中使用。
我认为它一定是我的节点模块之一使用它,但NodeSource 的这篇文章似乎表明警告仅抛出到文件夹之外node_modules。
无论这篇文章是否正确,我都会收到警告作为 iisnode 的输出,我什至让它向用户抛出错误页面,所以我想要一种方法来阻止它/删除已弃用的使用。即使有一种方法可以识别哪个节点模块导致了问题,这也会有所帮助。
我正在使用节点 v10.15.1
我想在 IIS 中部署 Nuxt,我正在使用 IIS Node,但我无法让它工作......

我可以在我的服务器中使用 npm run start 来完成它,但我还有其他项目,例如 admin y api (.net) 并且它使用端口 80,所以当我使用端口 80 时它很忙,而在 IIS 中它使用此结构

这是我在 web.config 中的代码
<?xml version="1.0" encoding="utf-8"?>
<!--
This configuration file is required if iisnode is used to run node processes behind
IIS or IIS Express. For more information, visit:
https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config
-->
<configuration>
<system.webServer>
<!-- Visit http://blogs.msdn.com/b/windowsazure/archive/2013/11/14/introduction-to-websockets-on-windows-azure-web-sites.aspx for more information on WebSocket support -->
<webSocket enabled="false" />
<handlers>
<!-- Indicates that the server.js file is a node.js site to be …Run Code Online (Sandbox Code Playgroud)