[英]Internal server error 500, hosting Node.js Express 4 application template from Visual Studio 2017 in Azure
I create a project from the project template: " Basic Azure Node.js Express 4 Application
" in Visual Studio 2017 Enterprise edition. 我从项目模板创建了一个项目:Visual Studio 2017 Enterprise Edition中的“
Basic Azure Node.js Express 4 Application
”。
When I run it locally it works fine. 当我在本地运行它时,它工作正常。 Now I publish this to Azure using the below
Publish
menu: 现在,使用下面的“
Publish
菜单将其Publish
到Azure:
I get the following error: 我收到以下错误:
iisnode encountered an error when processing the request.
HRESULT: 0x2
HTTP status: 500
HTTP subStatus: 1001
HTTP reason: Internal Server Error
I'm making no changes to the code from the template. 我没有对模板中的代码进行任何更改。
Any Ideas? 有任何想法吗?
I followed your steps in Visual Studio 2017 Community edition. 我在Visual Studio 2017社区版中按照您的步骤进行操作。 When I published the Express app to Azure Web App, I get the following error on my browser.
当我将Express应用程序发布到Azure Web App时,在浏览器上出现以下错误。
The page cannot be displayed because an internal server error has occurred.
由于发生内部服务器错误,因此无法显示该页面。
After some investigation, I fixed it by changing the Web.config
file to something like this: 经过一番调查后,我通过将
Web.config
文件更改为以下内容来修复该问题:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
<modules runAllManagedModulesForAllRequests="false" />
<iisnode watchedFiles="web.config;*.js;routes\*.js;views\*.pug" />
<handlers>
<add name="iisnode" path="bin/www" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^bin/www\/debug[\/]?" />
</rule>
<rule name="StaticContent">
<action type="Rewrite" url="public{REQUEST_URI}" />
</rule>
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True" />
</conditions>
<action type="Rewrite" url="bin/www" />
</rule>
</rules>
</rewrite>
<security>
<requestFiltering>
<hiddenSegments>
<remove segment="bin" />
</hiddenSegments>
</requestFiltering>
</security>
</system.webServer>
</configuration>
Also, the web.config
file can be found at https://github.com/projectkudu/kudu/wiki/Using-a-custom-web.config-for-Node-apps . 另外,可以在https://github.com/projectkudu/kudu/wiki/Using-a-custom-web.config-for-Node-apps中找到
web.config
文件。
Hope this will help you. 希望这会帮助你。
I also had the problem of 500 server errors, and couldn't figure out why node wasn't starting when I started the site. 我还遇到了500个服务器错误的问题,并且无法弄清楚为什么在启动站点时节点没有启动。 There were a couple different kinds of logs you can turn on, but
Diagnose and solve problems > Failed Request Tracing Logs
is what helped me. 您可以打开两种不同的日志,但是
Diagnose and solve problems > Failed Request Tracing Logs
对我有所帮助。
In the logs, I saw: 在日志中,我看到了:
Warning:
ModuleName="RewriteModule", Notification="SEND_RESPONSE", HttpStatus="500", HttpReason="URL Rewrite Module Error.", HttpSubStatus="52", ErrorCode="2152071471", ConfigExceptionInfo=""
ErrorDescription="The expression "^server\app.js\/debug[\/]?" contains an escape sequence that is not valid."
And the problem came down to using Windows path separator -NodeStartFile server\\app.js
instead of URL path separator -NodeStartFile server/app.js
in the Azure App Service Deploy task web.config parameter. 问题归结为在Azure App Service部署任务web.config参数中使用Windows路径分隔符
-NodeStartFile server\\app.js
而不是URL路径分隔符-NodeStartFile server/app.js
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.