node.js - 在Azure网站中运行nodeJS站点

标签 node.js azure azure-web-app-service

我正在尝试在 Windows Azure 网站中运行 nodeJS 站点。我刚刚 git 推送了两个文件:

服务器.js 包.json

以及来自 npm install 的所有模块。它在本地工作正常,但当我浏览 WA 网站时,我只是得到:

由于发生内部服务器错误,该页面无法显示。

我使用 CLI 来获取尾日志,但我只看到了这个:

<h3>HTTP Error 500.0 - Internal Server Error</h3> 
<h4>The page cannot be displayed because an internal server error has occurred.</h4> 
</div> 
<div class="content-container"> 
<fieldset><h4>Most likely causes:</h4> 
<ul>    <li>IIS received the request; however, an internal error occurred during the processing of the request. The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred.</li>    <li>IIS was not able to access the web.config file for the Web site or application. This can occur if the NTFS permissions are set incorrectly.</li>    <li>IIS was not able to process configuration for the Web site or application.</li>     <li>The authenticated user does not have permission to use this DLL.</li>   <li>The request is mapped to a managed handler but the .NET Extensibility Feature is not installed.</li> </ul> 
</fieldset> 
</div> 
<div class="content-container"> 
<fieldset><h4>Things you can try:</h4> 
<ul>    <li>Ensure that the NTFS permissions for the web.config file are correct and allow access to the Web server's machine account.</li>     <li>Check the event logs to see if any additional information was logged.</li>  <li>Verify the permissions for the DLL.</li>    <li>Install the .NET Extensibility feature if the request is mapped to a managed handler.</li>  <li>Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests, click <a href="http://go.microsoft.com/fwlink/?LinkID=66439">here</a>. </li> </ul> 

最佳答案

没有看到您实际的 server.js 代码(您应该将其插入到您的问题中),我只能猜测可能是什么问题。所以...我的猜测是您的 server.js 没有监听正确的端口(当然,我可能是错的...)。

node.js tutorial在 WindowsAzure.com 网站的 Node.js 开发人员部分中,有一个“Hello World”示例,该示例展示了如何从环境中获取端口:

var http = require('http')
var port = process.env.PORT || 1337;
http.createServer(function(req, res) {
    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.end('Hello World\n');
}).listen(port);

您不能只让服务器监听端口 80。您需要从 process.env.PORT 获取正确的端口。

希望这是您的问题...

关于node.js - 在Azure网站中运行nodeJS站点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17080049/

相关文章:

javascript - 迭代后返回 while 循环 - 当条件再次为真时?

azure - Azure Cosmos DB Gremlin 是否支持存储过程或自定义函数

azure - 我是否可以在同一部署槽中拥有具有通用应用程序设置名称但具有不同值的 Azure 网站和 webjobs?

java - Azure 应用程序服务为 Spring Boot 应用程序提供 404

html - AngularJS 显示 MongoDB 数据

javascript - Visual Studio 代码不会自动完成我的 javascript 方法

node.js - Twilio - 如何通过在 NodeJs 中提供调用 SID 来检索语音通话录音媒体文件

azure - 重定向安全域是否需要两个域上的 ssl 证书?

azure - 发布页面更改时出现问题

azure - 控制 Application Insights javascript 注入(inject)