Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 设置根路径以在Azure(IIS Web服务器)上提供index.html服务_Node.js_Azure_Iis - Fatal编程技术网

Node.js 设置根路径以在Azure(IIS Web服务器)上提供index.html服务

Node.js 设置根路径以在Azure(IIS Web服务器)上提供index.html服务,node.js,azure,iis,Node.js,Azure,Iis,我在Azure上部署了一个相当标准的节点应用程序。默认情况下,对于http:www.example.com/my_pathAzure的请求,会添加一个web.configxml文件来设置IIS,以便: a) 查看/public文件夹中是否存在与/my_path匹配的静态文件 b) 将所有其他请求路由到nodejs应用程序 这与我想要的很接近,除了根路径(http:www.example.com/)我希望它只显示public/index.html,并在此时将根路径路由到节点应用程序 我不能让它那样

我在Azure上部署了一个相当标准的节点应用程序。默认情况下,对于
http:www.example.com/my_path
Azure的请求,会添加一个
web.config
xml文件来设置IIS,以便:

a) 查看
/public
文件夹中是否存在与
/my_path
匹配的静态文件
b) 将所有其他请求路由到nodejs应用程序

这与我想要的很接近,除了根路径(
http:www.example.com/
)我希望它只显示
public/index.html
,并在此时将根路径路由到节点应用程序

我不能让它那样做。以下是我的
web.config
中的相关部分:


您可以尝试在
web.config
文件中添加和修改以下重写内容:

<rule name="SpecificRedirect" stopProcessing="true">
    <match url="/" />
    <action type="Rewrite" url="/index.html" />
</rule>
<!-- All other URLs are mapped to the node.js site entry point -->
<rule name="DynamicContent">
    <match url="/api" />
     <conditions>
          <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
     </conditions>
     <action type="Rewrite" url="app.js"/>
</rule>

如果请求与url
yourdomain
匹配,它将重写根目录中的
index.html
,并停止重新编写进程,该进程将显示node.js应用程序路由的
index.html
请求


还可以配置node.js应用程序来处理子模式中的请求
/api

在IIS.net的相关页面上花费一些时间。它展示了这么多的例子,你应该能够学会如何使用它,而不是依赖他人。@LexLi如果是你投票结束了这个问题,你能帮我理解为什么吗?我觉得我问了一个关于编程的特定问题,这个问题有一个明确的答案。stackoverflow的“离题”是什么?谢谢。如果您以前不知道,IIS配置问题属于ServerFault。Stackoverflow上的~25k IIS问题将表明情况并非如此: