简体   繁体   English

Azure子文件夹中的Node.js应用程序未运行

[英]Node.js app in Azure subfolder not running

We've tried everything with a colleague of mine, but we couldn't get it working :( We have a Web App in Azure - an MVC one. Inside of it we want to add a blog as a subfolder, but for now we test with a very simple express app. 我们已经和我的一位同事一起尝试了一切,但是我们无法让它工作:(我们在Azure中有一个Web应用程序 - 一个MVC。在其中我们想要添加一个博客作为子文件夹,但是现在我们用一个非常简单的快递应用程序测试

Basically, we have the main MVC app. 基本上,我们有主要的MVC应用程序。 I've tried both moving my small test node.js app to site\\test and site\\wwwroot\\test. 我已经尝试将我的小型测试node.js应用程序移动到site \\ test和site \\ wwwroot \\ test。 There is a virtual application /test pointing to site/test. 有一个指向站点/测试的虚拟应用程序/测试。 (from the Azure portal Application Settings). (来自Azure门户应用程序设置)。

Inside the test folder, web.config: 在测试文件夹中,web.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>
        <handlers>
            <add name="iisnode" path="index.js" verb="*" modules="iisnode" />
        </handlers>
        <rewrite>
            <rules>
                <rule name="DynamicContent">
                    <action type="Rewrite" url="index.js" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

index.js index.js

var express = require('express');
var app = express();

console.log(1);

app.get('/', function (req, res) {
  res.send('Hello World!');
});

app.listen(process.env.PORT || 3000, function () {
  console.log('Test is live');
});

package.json 的package.json

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "express": "^4.14.0"
  }
}

After I try to open http://MySite.azurewebsites.net/test/ and then open the main site from FTP and go to LogFiles/DetailedErrors, there are two errors: 在我尝试打开http://MySite.azurewebsites.net/test/然后从FTP打开主站点并转到LogFiles / DetailedErrors之后,有两个错误:

HTTP Error 500.1000 - Internal Server Error
Detailed Error Information:
Module     iisnode
Notification       ExecuteRequestHandler
Handler    iisnode
Error Code     0x8007000d
Requested URL      http://MySite:80/test/index.js
Physical Path      D:\home\site\wwwroot\test\index.js
Logon Method       Anonymous
Logon User     Anonymous

and

HTTP Error 403.14 - Forbidden
Detailed Error Information:
Module     DirectoryListingModule
Notification       ExecuteRequestHandler
Handler    StaticFile
Error Code     0x00000000
Requested URL      http://MySite:80/test/
Physical Path      D:\home\site\wwwroot\test\
Logon Method       Anonymous
Logon User     Anonymous

Finally, here's the main app web.config. 最后,这是主要的应用程序web.config。 I suspect it might hold the key to the problem: 我怀疑它可能是解决问题的关键:

<?xml version="1.0" encoding="utf-8"?>
<configuration>  
  <configSections>    
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <sectionGroup name="jsEngineSwitcher">
      <section name="core" type="JavaScriptEngineSwitcher.Core.Configuration.CoreConfiguration, JavaScriptEngineSwitcher.Core" />
      <section name="msie" type="JavaScriptEngineSwitcher.Msie.Configuration.MsieConfiguration, JavaScriptEngineSwitcher.Msie" />
      <section name="v8" type="JavaScriptEngineSwitcher.V8.Configuration.V8Configuration, JavaScriptEngineSwitcher.V8" />
    </sectionGroup>
  </configSections>  
  <connectionStrings>
    some conn strings
  </connectionStrings>    
  <location path="." inheritInChildApplications="false">
    <appSettings>
      <add key="webpages:Version" value="3.0.0.0" />
      <add key="webpages:Enabled" value="false" />
      <add key="ClientValidationEnabled" value="true" />
      <add key="UnobtrusiveJavaScriptEnabled" value="true" />      
      <add key="webpages:Enabled" value="true" />
      <add key="webpages:Version" value="3.0.0.0" />
    </appSettings>
  </location>
  <location path="." inheritInChildApplications="false">
    <system.web>      
      <authentication mode="None" />
      <compilation debug="true" targetFramework="4.5" />
      <httpRuntime targetFramework="4.5" />
      <httpHandlers>
        <add path="*.png" verb="*" type="System.Web.StaticFileHandler" validate="true" />
        <add path="*.js" verb="*" type="System.Web.StaticFileHandler" validate="true" />        
      </httpHandlers>      
    </system.web>
  </location>
  <location path="." inheritInChildApplications="false">
    <system.webServer>    
      <validation validateIntegratedModeConfiguration="false" />
      <modules runAllManagedModulesForAllRequests="true">
        <remove name="FormsAuthentication" />
      </modules>
      <staticContent>
        <remove fileExtension=".eot" />
        <remove fileExtension=".ttf" />
        <remove fileExtension=".otf" />
        <remove fileExtension=".woff" />
        <remove fileExtension=".woff2" />
        <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
        <mimeMap fileExtension=".ttf" mimeType="font/ttf" />
        <mimeMap fileExtension=".otf" mimeType="font/otf" />
        <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
        <mimeMap fileExtension=".woff2" mimeType="application/font-woff" />
        <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="14.00:00:00" />
      </staticContent>
      <security>
        <requestFiltering>
          <hiddenSegments>
            <add segment="ClearScript.V8" />
          </hiddenSegments>
        </requestFiltering>
      </security>
      <handlers>
        <remove name="Babel" />
        <add name="Babel" verb="GET" path="*.jsx" type="React.Web.BabelHandlerFactory, React.Web" preCondition="integratedMode" />
      </handlers>     
      <directoryBrowse enabled="false" />
    </system.webServer>
  </location>  
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
  <jsEngineSwitcher xmlns="http://tempuri.org/JavaScriptEngineSwitcher.Configuration.xsd">
    <core>
      <engines>
        <add name="MsieJsEngine" type="JavaScriptEngineSwitcher.Msie.MsieJsEngine, JavaScriptEngineSwitcher.Msie" />
        <add name="V8JsEngine" type="JavaScriptEngineSwitcher.V8.V8JsEngine, JavaScriptEngineSwitcher.V8" />
      </engines>
    </core>
  </jsEngineSwitcher>
</configuration>

We've tried everything we can find online and nothing is working :( Would really appreciate some help! 我们已经尝试了我们在网上找到的所有东西,但没有任何工作:(非常感谢一些帮助!

Here is an answer of IIS, Node.js, and Web Application with IISNode not configured right with Virtual Directory , which is in the same scenario with you. 以下是IIS,Node.js和Web应用程序的答案, IISNode没有配置正确的虚拟目录 ,与您在同一场景中。 I tested this answer on locally, and it worked fine. 我在本地测试了这个答案,它运行良好。

I built an empty MVC application, and put a simple expressjs application into it with the web.config similar with http://tstrimple.com/express-4-azure-websites/ . 我建立了一个空的MVC应用程序,并把一个简单的expressjs应用到它的web.config有类似http://tstrimple.com/express-4-azure-websites/

And I didn't config any location tag in the MVC's web.config file. 我没有在MVC的web.config文件中配置任何位置标记。

Any further concern, please feel free to let me know. 如有任何疑问,请随时告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM