【发布时间】:2018-05-03 15:21:45
【问题描述】:
我们目前在 Windows WebApp 上部署 Node.js 应用程序时遇到了一些麻烦,我们怀疑问题出在 web.config 文件中。
这是项目目录结构:
我们使用默认的 web.config 并进行了一些更改: 应用文件是app.js,公共文件夹是dist/
<?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 handled by the iisnode module -->
<add name="iisnode" path="app.js" verb="*" modules="iisnode"/>
</handlers>
<rewrite>
<rules>
<!-- Do not 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="dist{REQUEST_URI}"/>
</rule>
<!-- All other URLs are mapped to the node.js site entry point -->
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
</conditions>
<action type="Rewrite" url="app.js"/>
</rule>
</rules>
</rewrite>
<!-- 'bin' directory has no special meaning in node.js and apps can be placed in it -->
<security>
<requestFiltering>
<hiddenSegments>
<remove segment="bin"/>
</hiddenSegments>
</requestFiltering>
</security>
<!-- Make sure error responses are left untouched -->
<httpErrors existingResponse="PassThrough" />
<!--
You can control how Node is hosted within IIS using the following options:
* watchedFiles: semi-colon separated list of files that will be watched for changes to restart the server
* node_env: will be propagated to node as NODE_ENV environment variable
* debuggingEnabled - controls whether the built-in debugger is enabled
See https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config for a full list of options
-->
<!--<iisnode watchedFiles="web.config;*.js"/>-->
</system.webServer>
</configuration>
目前,IIS 重写模块正在将 dist/ 添加到 URL,如下所示:http://xxxxxxx.azurewebsites.net/dist/
我们有一个 iisnode 错误消息:
HRESULT:0x2
HTTP 状态:500
HTTP 子状态:1001
HTTP 原因:内部服务器错误
我尝试检查失败的请求跟踪日志,但没有记录失败的请求。
有人能告诉我我的情况发生了什么吗?
编辑:
我决定从头开始并创建一个新的网络应用程序。
我使用 kudu 控制台构建了 node.js 应用程序,并且(使用相同的 web.config)服务器现在可以正确获取 dist/ 中的 index.html 文件.
到目前为止一切顺利,我们正确地登陆了登录页面。
现在的问题是 iisnode 无法使用用户凭据处理 POST 请求。
按照 Julien 的建议,我尝试更改应用程序的虚拟目录并出现不同的错误:
第一种情况:虚拟目录: /
路径: site\wwwroot
错误:同上的iisnode错误 p>
第二种情况:
虚拟目录: /
路径: site\wwwroot\dist
错误:您要查找的资源有已被删除、名称已更改或暂时不可用。
对此有什么想法吗?
谢谢
【问题讨论】:
标签: azure azure-web-app-service iisnode