最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

Azure上的Web应用程序的Linux或Windows无法到达现场的NodeJS

IT培训 admin 3浏览 0评论

Azure上的Web应用程序的Linux或Windows无法到达现场的NodeJS

有一个真正的很难得到部署到Azure上我的web应用程序。我可以运行NPM启动并将它编译和运行在本地主机上没有问题的端口4200。

我可以通过git的部署到Azure中,然后ssh和NPM安装一切,编译它。但无论我做什么去的网站的网址.azurewebsites我总是得到“无法GET /”

我不知道我错过了什么。这是服务器上的结构

-~/wwwroot/
   -frontend/
     -angular.json
     -node_modules/
     -src/
       -index.js
       -main.ts
       -index.html
       -app/
       -styles.scss
       -environments/
       -tsconfig.app.json
     -index.js
     -package.json
     -e2e/
     -proxy.conf.json
     -protractor.conf.js
     -tsconfig.json
     -package-lock.json
     -web.config
   -server/
     -app.properties
     -pom.xml
     -src/
     -mvnw
     -mvnw.cmd

我不知道所有的文件都在这一点上相关,但我会贴上一些似乎像他们可能是:

的package.json

{
  "name": "blah",
  "version": "0.1.1",
  "scripts": {
    "ng": "ng",
    "start": "node app.js",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
    "private": true,
    "engines":{"node": "8.10.0"},  
    "dependencies": {
    "@angular/animations": "^7.1.4",
    "@angular/cdk": "5.0.0-rc.1",
    "@angular/common": "^7.1.4",
    "@angular/compiler": "^7.1.4",
    "@angular/core": "^7.1.4",
    "@angular/flex-layout": "^2.0.0-beta.10-4905443",
    "@angular/forms": "^7.1.4",
    "@angular/http": "^7.1.4",
    "@angular/material": "5.0.0-rc.1",
    "@angular/platform-browser": "^7.1.4",
    "@angular/platform-browser-dynamic": "^7.1.4",
    "@angular/platform-server": "^7.1.4",
    "@angular/router": "^7.1.4",
    "angular-tree-component": "^8.0.1",
    "chart.js": "^2.7.3",
    "core-js": "^2.6.1",
    "hammerjs": "2.0.8",
    "ng-treetable": "^1.3.3",
    "ng2-charts": "^1.6.0",
    "rxjs": "6.2.2",
    "rxjs-compat": "^6.3.3",
    "zone.js": "^0.8.26"
  },
   "devDependencies": {
     "@angular-devkit/build-angular": "^0.11.4",
     "@angular-devkit/core": "^0.6.3",
     "@angular/cli": "^7.1.4",
     "@angular/compiler-cli": "^7.1.4",
     "@angular/language-service": "^7.1.4",
     "@types/hammerjs": "2.0.34",
     "@types/jasmine": "^3.3.4",
     "@types/jasminewd2": "2.0.3",
     "@types/node": "^10.12.18",
     "codelyzer": "^4.5.0",
     "jasmine-core": "^3.3.0",
     "jasmine-spec-reporter": "^4.2.1",
     "karma": "^3.1.4",
     "karma-chrome-launcher": "^2.2.0",
     "karma-cli": "^2.0.0",
     "karma-coverage-istanbul-reporter": "1.3.0",
     "karma-jasmine": "^2.0.1",
     "karma-jasmine-html-reporter": "^1.4.0",
     "protractor": "^5.4.1",
     "rxjs-tslint": "^0.1.6",
     "ts-node": "3.0.6",
     "tslint": "^5.12.0",
     "typescript": "^3.1.6",
     "webpack": "^4.28.1"
   }
 }

APP-routing.module.ts

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AppComponent } from './appponent';
import { HomeComponent } from './home';
import { LoginComponent } from './login';
import { AdminComponent } from './admin';
import { LoginGuard } from './guard';
import { GuestGuard, AdminGuard } from './guard';
import { NotFoundComponent } from './not-found';
import { ForbiddenComponent } from './forbidden';

export const routes: Routes = [
 {
  path: '',
  component: HomeComponent,
  pathMatch: 'full'
 },
 {
  path: 'login',
  component: LoginComponent,
  canActivate: [GuestGuard]
 },
 {
   path: 'admin',
   component: AdminComponent,
   canActivate: [AdminGuard]
 },
 {
  path: '404',
  component: NotFoundComponent
 },
 {
  path: '403',
  component: ForbiddenComponent
 },
{
  path: '**',
  redirectTo: '/404'
}
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule],
  providers: []
  })
  export class AppRoutingModule { }

proxy.conf.json

{
  "/api": {
  "target": "http://localhost:4200",
  "secure": false
 }
}

我在需要的web.config文件?

UPDATE

我添加以下到〜/前端/和〜/前端/ src目录/同样改变了的package.json开始到“节点index.js”再次按预期工作localy运行,并导航到默认的端口,但在行为上没有变化Azure上。

app.js

var http = require('http');
var server = http.createServer(function(request, response) {
 response.writeHead(200, {"Content-Type": "text/plain"});
 response.end("Hello World!");
});

var port = process.env.PORT || 4200;
server.listen(port);

console.log("Server running at http://localhost:%d", port);

UPDATE2

我做了一堆的变化和got..somewhere ......从Linux到Windows机器改变。难道NPM安装finagaling

添加一个web.config和app.js

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

如果我把在web.config根我得到一个HTTP 500响应。规定的东西“格式不正确的配置文件”的影响

如果我把它在前端DIR我收到了约403目录列表。

回答如下:

我觉得你的问题是,你不能达到我所看到使用下面的代码片段的端口4200。大多数示例:

var port = process.env.PORT || 1337;
server.listen(port);

Here is the code example从他们的文档。默认情况下,端口80或8080设置。我曾经历过类似的问题与部署泊坞窗容器。

Azure上的Web应用程序的Linux或Windows无法到达现场的NodeJS

有一个真正的很难得到部署到Azure上我的web应用程序。我可以运行NPM启动并将它编译和运行在本地主机上没有问题的端口4200。

我可以通过git的部署到Azure中,然后ssh和NPM安装一切,编译它。但无论我做什么去的网站的网址.azurewebsites我总是得到“无法GET /”

我不知道我错过了什么。这是服务器上的结构

-~/wwwroot/
   -frontend/
     -angular.json
     -node_modules/
     -src/
       -index.js
       -main.ts
       -index.html
       -app/
       -styles.scss
       -environments/
       -tsconfig.app.json
     -index.js
     -package.json
     -e2e/
     -proxy.conf.json
     -protractor.conf.js
     -tsconfig.json
     -package-lock.json
     -web.config
   -server/
     -app.properties
     -pom.xml
     -src/
     -mvnw
     -mvnw.cmd

我不知道所有的文件都在这一点上相关,但我会贴上一些似乎像他们可能是:

的package.json

{
  "name": "blah",
  "version": "0.1.1",
  "scripts": {
    "ng": "ng",
    "start": "node app.js",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
    "private": true,
    "engines":{"node": "8.10.0"},  
    "dependencies": {
    "@angular/animations": "^7.1.4",
    "@angular/cdk": "5.0.0-rc.1",
    "@angular/common": "^7.1.4",
    "@angular/compiler": "^7.1.4",
    "@angular/core": "^7.1.4",
    "@angular/flex-layout": "^2.0.0-beta.10-4905443",
    "@angular/forms": "^7.1.4",
    "@angular/http": "^7.1.4",
    "@angular/material": "5.0.0-rc.1",
    "@angular/platform-browser": "^7.1.4",
    "@angular/platform-browser-dynamic": "^7.1.4",
    "@angular/platform-server": "^7.1.4",
    "@angular/router": "^7.1.4",
    "angular-tree-component": "^8.0.1",
    "chart.js": "^2.7.3",
    "core-js": "^2.6.1",
    "hammerjs": "2.0.8",
    "ng-treetable": "^1.3.3",
    "ng2-charts": "^1.6.0",
    "rxjs": "6.2.2",
    "rxjs-compat": "^6.3.3",
    "zone.js": "^0.8.26"
  },
   "devDependencies": {
     "@angular-devkit/build-angular": "^0.11.4",
     "@angular-devkit/core": "^0.6.3",
     "@angular/cli": "^7.1.4",
     "@angular/compiler-cli": "^7.1.4",
     "@angular/language-service": "^7.1.4",
     "@types/hammerjs": "2.0.34",
     "@types/jasmine": "^3.3.4",
     "@types/jasminewd2": "2.0.3",
     "@types/node": "^10.12.18",
     "codelyzer": "^4.5.0",
     "jasmine-core": "^3.3.0",
     "jasmine-spec-reporter": "^4.2.1",
     "karma": "^3.1.4",
     "karma-chrome-launcher": "^2.2.0",
     "karma-cli": "^2.0.0",
     "karma-coverage-istanbul-reporter": "1.3.0",
     "karma-jasmine": "^2.0.1",
     "karma-jasmine-html-reporter": "^1.4.0",
     "protractor": "^5.4.1",
     "rxjs-tslint": "^0.1.6",
     "ts-node": "3.0.6",
     "tslint": "^5.12.0",
     "typescript": "^3.1.6",
     "webpack": "^4.28.1"
   }
 }

APP-routing.module.ts

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AppComponent } from './appponent';
import { HomeComponent } from './home';
import { LoginComponent } from './login';
import { AdminComponent } from './admin';
import { LoginGuard } from './guard';
import { GuestGuard, AdminGuard } from './guard';
import { NotFoundComponent } from './not-found';
import { ForbiddenComponent } from './forbidden';

export const routes: Routes = [
 {
  path: '',
  component: HomeComponent,
  pathMatch: 'full'
 },
 {
  path: 'login',
  component: LoginComponent,
  canActivate: [GuestGuard]
 },
 {
   path: 'admin',
   component: AdminComponent,
   canActivate: [AdminGuard]
 },
 {
  path: '404',
  component: NotFoundComponent
 },
 {
  path: '403',
  component: ForbiddenComponent
 },
{
  path: '**',
  redirectTo: '/404'
}
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule],
  providers: []
  })
  export class AppRoutingModule { }

proxy.conf.json

{
  "/api": {
  "target": "http://localhost:4200",
  "secure": false
 }
}

我在需要的web.config文件?

UPDATE

我添加以下到〜/前端/和〜/前端/ src目录/同样改变了的package.json开始到“节点index.js”再次按预期工作localy运行,并导航到默认的端口,但在行为上没有变化Azure上。

app.js

var http = require('http');
var server = http.createServer(function(request, response) {
 response.writeHead(200, {"Content-Type": "text/plain"});
 response.end("Hello World!");
});

var port = process.env.PORT || 4200;
server.listen(port);

console.log("Server running at http://localhost:%d", port);

UPDATE2

我做了一堆的变化和got..somewhere ......从Linux到Windows机器改变。难道NPM安装finagaling

添加一个web.config和app.js

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

如果我把在web.config根我得到一个HTTP 500响应。规定的东西“格式不正确的配置文件”的影响

如果我把它在前端DIR我收到了约403目录列表。

回答如下:

我觉得你的问题是,你不能达到我所看到使用下面的代码片段的端口4200。大多数示例:

var port = process.env.PORT || 1337;
server.listen(port);

Here is the code example从他们的文档。默认情况下,端口80或8080设置。我曾经历过类似的问题与部署泊坞窗容器。

发布评论

评论列表 (0)

  1. 暂无评论