Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/83.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 IIS服务器中的主机Nodejs应用程序_Node.js_Express_Iis 7_Web Config_Iisnode - Fatal编程技术网

Node.js IIS服务器中的主机Nodejs应用程序

Node.js IIS服务器中的主机Nodejs应用程序,node.js,express,iis-7,web-config,iisnode,Node.js,Express,Iis 7,Web Config,Iisnode,我使用iisnode在IIS服务器上托管了一个NodeJs express应用程序。应用程序正在节点服务器上运行,没有给出任何错误。它给了我iisnode的以下错误。 使用的Express版本是4.13.4 我已经为IIS安装了URL重写模块 我的server.js文件如下 'use strict'; // Module dependencies. var express = require('express'), path = require('path'), fs = r

我使用iisnode在IIS服务器上托管了一个NodeJs express应用程序。应用程序正在节点服务器上运行,没有给出任何错误。它给了我iisnode的以下错误。 使用的Express版本是4.13.4

我已经为IIS安装了URL重写模块

我的server.js文件如下

'use strict';

// Module dependencies.
var express = require('express'),
    path = require('path'),
    fs = require('fs'),
    cors = require('cors'),
    methodOverride = require('method-override'),
    morgan = require('morgan'),
    bodyParser = require('body-parser');

var app = module.exports = exports.app = express();

app.locals.siteName = "IOS IBE";
app.use(cors());
//cors and preflight filtering
app.all('*', function (req, res, next) {
//preflight needs to return exact request-header
    res.set('Access-Control-Allow-Headers',
        req.headers['access-control-request-headers']);
    if ('OPTIONS' == req.method)
        return res.send(204);
    next();
});
app.use(express.static(__dirname + '/public'));

app.get('/*', function (req, res) {
    res.sendFile(__dirname + '/public/index.html');
});

app.use(methodOverride());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));

// Start server
var port = 4015;
app.listen(port, function () {
    console.log('Distributor portal App manager server listening on port %d in %s mode', port, app.get('env'));
});
我的web.conf如下

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>         
      <handlers>
           <add name="iisnode" path="server.js" verb="*" modules="iisnode"/>
     </handlers>
      <rewrite>
           <rules>

                <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">                    
                    <match url="^server.js\/debug[\/]?" />
                </rule>

                <rule name="StaticContent">
                     <action type="Rewrite" url="public{REQUEST_URI}"/>
                </rule>

                <rule name="DynamicContent">
                     <conditions>
                          <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
                     </conditions>
                     <action type="Rewrite" url="server.js"/>
                </rule>

           </rules>
      </rewrite>
   </system.webServer>
 </configuration>


您能在IIS ARR中显示您的代理配置吗?我也添加了我的web.conf。这就是你想要的吗?哦。。。这和我想象的有点不同让我检查一下文件。您是否遵循以下步骤:?@JanithWidarshana使用process.env.PORT而不是PORT(4015)@JanithWidarshana由于IIS控制所有HTTP侦听器的基址,因此node.js应用程序必须使用iisnode模块通过process.env.PORT环境变量提供的侦听地址,而不是指定自己的侦听地址。