[英]Node.js on Windows Azure IIS using IISNode: How to set startup file?
我正在使用IISNode通过Windows Azure上的IIS服务器来处理Node.js文件。 但是,当我尝试使用http://127.0.0.1/mysite/node/
访问服务器路径时,抛出以下错误
iisnode encountered an error when processing the request.
HRESULT: 0x2
HTTP status: 500
HTTP reason: Internal Server Error
在iisnode文件夹中生成的日志文件中,它显示以下错误:
Application has thrown an uncaught exception and is terminated:
Error: Cannot find module 'D:\Project\Files\mysite\node"'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:286:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (C:\Program Files\iisnode\interceptor.js:210:1)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:475:10)
但是,当我尝试使用此路径http://127.0.0.1/mysite/node/app.js
它将执行app.js文件。 但是,我不想在URL中显示app.js文件名。 使用此路径http://127.0.0.1/mysite/node/
时,可以将此文件设置为默认文件还是启动文件?
更新
进一步我的回答如下:
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
</conditions>
<action type="Rewrite" url="node/main.js"/>
</rule>
配置中的这段代码阻止了对任何.net文件的调用,而是将其重定向到要执行的节点。 仅当URL末尾包含/node/
时(如http://127.0.0.1/mysite/node/
如何才能重定向到节点?
我认为此解决方案有效。
现在评估...
更新
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
</conditions>
<action type="Rewrite" url="node/main.js"/>
</rule>
config中的这段代码阻止了对任何.net文件的调用,并且正在重定向到node以便执行。
仅当URL末尾包含/node/
时(如http://127.0.0.1/mysite/node/
如何才能重定向到节点?
我们可以利用web.config文件中的location
元素来确定应该将特定目录中的所有文件都视为node.js应用程序。
这是iis中我的站点目录图:
这是web.config
的内容: <configuration> <location path="node"> <system.webServer> <handlers> <add name="iisnode" path="*.js" verb="*" modules="iisnode" /> </handlers>
</system.webServer> </location> </configuration><configuration> <location path="node"> <system.webServer> <handlers> <add name="iisnode" path="*.js" verb="*" modules="iisnode" /> </handlers>
</system.webServer> </location> </configuration>
像http://localhost /mysite/node
这样的URL将由iisnode在web.config
配置。
并且其他将不受iisnode的影响,例如,在此测试中, http://localhost /mysite/php/index.php
仍运行PHP脚本。
有关更多信息,请参见在Windows上的IIS中托管node.js应用程序中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.