Node.js 在azure中的nodejs express应用程序中托管子ASP应用程序
Q1)我的主应用程序是用nodejs express构建的。我有一个使用asp.net制作的子应用程序,我想在我的主应用程序中作为虚拟应用程序托管它。我有什么办法可以做到这一点吗 目前,我的节点正在处理呼叫Node.js 在azure中的nodejs express应用程序中托管子ASP应用程序,node.js,web-config,azure-web-app-service,Node.js,Web Config,Azure Web App Service,Q1)我的主应用程序是用nodejs express构建的。我有一个使用asp.net制作的子应用程序,我想在我的主应用程序中作为虚拟应用程序托管它。我有什么办法可以做到这一点吗 目前,我的节点正在处理呼叫https://localhost:5000/mysite1作为目录,并给出404错误 我的文件夹结构看起来像 index.html server.js scripts web.config (*) ----- mysite1 |----- bin |----- Con
https://localhost:5000/mysite1
作为目录,并给出404错误
我的文件夹结构看起来像
index.html
server.js
scripts
web.config (*)
----- mysite1
|----- bin
|----- Controllers
|----- Pages
|----- Scripts
|----- web.config (**)
Q2从长远来看,我希望将应用程序带到Azure应用程序服务并在那里托管。运行时堆栈将是节点12 LTS。这在Azure中可能吗
nodejs应用程序的My web.config文件
<?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="server.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="^server.js\/debug[\/]?" />
</rule>
<!-- Do not interfere with requests for node-inspector debugging -->
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^cot" />
</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 site entry point -->
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
</conditions>
<action type="Rewrite" url="server.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"/>-->
<staticContent>
<remove fileExtension=".json"/>
<mimeMap fileExtension=".json" mimeType="application/json"/>
</staticContent>
</system.webServer>
</configuration>
虚拟应用程序目录结构应该如下所示
wwwroot
|----- index.html
|----- server.js
|----- scripts
|----- web.config (*)
mysite1
|----- bin
|----- Controllers
|----- Pages
|----- Scripts
|----- web.config (**)
更多细节,你可以在下面的帖子中查看我的答案
我尝试了上述结构,但我的server.js收到了所有对mysite1的调用。所以我猜我必须在我的web.config或server.js中更改某些内容才能允许这种情况发生?我在服务器中提供了一段路由。js@user7278236您应该使用
virtual
路径发送http请求。这是另一个问题。你可以用谷歌搜索。
wwwroot
|----- index.html
|----- server.js
|----- scripts
|----- web.config (*)
mysite1
|----- bin
|----- Controllers
|----- Pages
|----- Scripts
|----- web.config (**)