我使用节点提供的Web服务器在本地运行基本的express 4应用程序。
我尝试在Webmatrix中查看/编辑并使用IIS,然后我可以将其作为节点应用程序上传到Azure。 Azure的模板使用旧版本的node和express。
使用IIS从Webmatrix运行时 - 当发布到Azure时,我会收到以下内容:
HRESULT: 0x2
HTTP status: 500
HTTP reason: Internal Server Error
我认为该问题与web.config文件有某种关系,但我发现的所有文章和修正都已过时且未解决问题。
我的web.config文件:
<configuration>
<system.webServer>
<handlers>
<!-- indicates that the app.js file is a node.js application to be handled by the iisnode module -->
<add name="iisnode" path="app.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<!-- Don't interfere with requests for node-inspector debugging -->
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^app.js\/debug[\/]?" />
</rule>
<!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
<rule name="StaticContent">
<action type="Rewrite" url="public{REQUEST_URI}" />
</rule>
<!-- All other URLs are mapped to the Node.js application entry point -->
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True" />
</conditions>
<action type="Rewrite" url="app.js" />
</rule>
</rules>
</rewrite>
<!-- You can control how Node is hosted within IIS using the following options -->
<!--
<iisnode
node_env="%node_env%"
nodeProcessCountPerApplication="1"
maxConcurrentRequestsPerProcess="1024"
maxNamedPipeConnectionRetry="3"
namedPipeConnectionRetryDelay="2000"
maxNamedPipeConnectionPoolSize="512"
maxNamedPipePooledConnectionAge="30000"
asyncCompletionThreadCount="0"
initialRequestBufferSize="4096"
maxRequestBufferSize="65536"
watchedFiles="*.js"
uncFileChangesPollingInterval="5000"
gracefulShutdownTimeout="60000"
loggingEnabled="true"
logDirectoryNameSuffix="logs"
debuggingEnabled="true"
debuggerPortRange="5058-6058"
debuggerPathSegment="debug"
maxLogFileSizeInKB="128"
appendToExistingLog="false"
logFileFlushInterval="5000"
devErrorsEnabled="true"
flushResponse="false"
enableXFF="false"
promoteServerVars=""
/>
-->
</system.webServer>
</configuration>
我已联系Azure团队,他们已经开始讨论,但我更加相信stackoverflow用户可以提供的内容。
答案 0 :(得分:1)
@Matthew,
这是我的猜测,我认为你没有配置你的应用程序,以便在部署到azure应用程序服务时收听正确的端口。您将需要执行类似于以下代码的操作,以便从环境中获取端口号&#34; process.env.port&#34;
var app = require('express')();
var port = process.env.port || 8080; // 8080 for local or whatever number u want
var listener = app.listen(port, function(){
console.log('Listening on port ' + port);
});