1

创建了 express-gateway 应用程序,现在我正在尝试在 azure 上进行部署,并为此创建了Azure App Service,一旦创建应用程序服务而不是使用Github部署过程,在应用程序服务上部署代码,现在当我尝试在浏览器上访问应用程序服务时我收到500.1001 错误,日志消息就像iisnode 无法建立到 node.exe 进程的命名管道连接

网页配置

<?xml version="1.0" encoding="utf-8"?>
  <!--
For more information on how to configure your Node.js application, please visit
http://go.microsoft.com/fwlink/?LinkId=290972
-->
  <configuration>
  <appSettings>
  <!--
  <add key="StorageAccountName" value="" />
  <add key="StorageAccountKey" value="" />
  <add key="ServiceBusNamespace" value="" />
  <add key="ServiceBusIssuerName" value="" />
  <add key="ServiceBusIssuerSecretKey" value="" />
  -->
  </appSettings>
  <system.webServer>
  <!-- mimeMap enables IIS to serve particular file types as specified by fileExtension. -->
  <staticContent>
  <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
  </staticContent>

  <modules runAllManagedModulesForAllRequests="false" />

  <!-- Web.Debug.config adds attributes to this to enable remote debugging when publishing in Debug configuration. -->
  <iisnode watchedFiles="web.config;*.js;routes\*.js;views\*.pug"/>

  <!-- Remote debugging (Azure Website with git deploy): Comment out iisnode above, and uncomment iisnode below. -->
  <!--<iisnode watchedFiles="web.config;*.js;routes\*.js;views\*.pug"
loggingEnabled="true"
devErrorsEnabled="true"
nodeProcessCommandLine="node.exe &#45;&#45;debug"/>-->

  <!-- indicates that the server.js file is a Node.js application
to be handled by the iisnode module -->
  <handlers>
  <add name="iisnode" path="server.js" verb="*" modules="iisnode" />

  <!-- Remote debugging (Azure Website with git deploy): Uncomment NtvsDebugProxy handler below.
Additionally copy Microsoft.NodejsTools.WebRole to 'bin' from the Remote Debug Proxy folder.-->
  <!--<add name="NtvsDebugProxy" path="ntvs-debug-proxy/f45f6d32-816b-47f0-8bfa-47f7930108a4" verb="*" resourceType="Unspecified"
type="Microsoft.NodejsTools.Debugger.WebSocketProxy, Microsoft.NodejsTools.WebRole"/>-->
  </handlers>

  <security>
  <requestFiltering>
  <hiddenSegments>
  <remove segment="bin" />
  </hiddenSegments>
  </requestFiltering>
  </security>

  <rewrite>
  <rules>
  <clear />
  <!-- Remote debugging (Azure Website with git deploy): Uncomment the NtvsDebugProxy rule below. -->
  <!--<rule name="NtvsDebugProxy" enabled="true" stopProcessing="true">
  <match url="^ntvs-debug-proxy/.*"/>
  </rule>-->

  <!-- Don't interfere with requests for node-inspector debugging -->
        <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
          <match url="^server.js\/debug[\/]?" />
        </rule>

        <rule name="app" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
          <match url="iisnode.+" negate="true" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
          <action type="Rewrite" url="server.js" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>

  <!-- Remote debugging (Azure Website with git deploy): uncomment system.web below -->
  <!--<system.web>
    <httpRuntime targetFramework="4.5"/>
    <customErrors mode="Off"/>
  </system.web>-->
  </configuration>

服务器.js

require('dotenv').config();
var request = require('request');

const path = require('path');
const gateway = require('express-gateway');

gateway()
  .load(path.join(__dirname, 'config'))
  .run();

网关.config.yml

http:
  port: 8080
admin:
  port: 9876
  host: localhost
apiEndpoints:
  api:
    host: localhost
    paths: '/ip'
serviceEndpoints:
  httpbin:
    url: 'https://httpbin.org'
policies:
  - basic-auth
  - cors
  - expression
  - key-auth
  - log
  - oauth2
  - proxy
  - rate-limit
pipelines:
  default:
    apiEndpoints:
      - api
    policies:
    # Uncomment `key-auth:` when instructed to in the Getting Started guide.
    # - key-auth:
      - proxy:
          - action:
              serviceEndpoint: httpbin 
              changeOrigin: true

在此处输入图像描述

4

0 回答 0