I have several iisnode applications running on a server. They all have application pools, web.config, and server.js. They all work, except for one.
Our internal DNS is setup to recognize this URL.
I've been over the web.config and server.js files and can't find any reason for the application to not load. If I run 'ng serve --port 3500' - it will appear on localhost:3500 so the application is ok. if I run 'node server.js' the application loads on port 8090 (as per the server.js file).
If I'm running 'node server.js' the application won't load via the URL, but will run via servername:8090
server.js
var serverType = 'AM-LMS EDITOR';
var express = require('express');
var http = require('http');
var path = require('path');
var bodyParser = require('body-parser');
var app = express();
var port = process.env.PORT || 8090;
app.use(function(req,res,next){
res.header("Access-Control-Allow-Origin","*");
res.header("Access-Control-Allow-Methods", "GET,HEAD,OPTIONS,POST,PUT");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, x-client-key, x-client-token, x-client-secret, Authorization");
next();
});
app.use(express.static(__dirname + '/dist/am-lms-admin'));
//body parse
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ limit: '50mb',extended: true }))
// parse application/json
app.use(bodyParser.json({limit: '50mb', extended: true}))
app.get('/*', (req,res) => res.sendFile(path.join(__dirname)));
app.all('/*', function(req, res, next) {
// Just send the index.html for other files to support HTML5Mode
res.sendFile('/dist/am-lms-admin/index.html', { root: __dirname });
});
// Handle 404
app.use(function(req, res) {
//res.send(‘404: Page not Found’, 404);
res.status(404).send({status:404, message: '404 Not Found', type:'client'});
});
/// Handle 500
app.use(function(error, req, res, next) {
res.status(500).send({status:500, message: 'internal error', type:'internal'});
});
//listen
var httpServer = http.createServer(app);
httpServer.listen(port,() => console.log(serverType +' server running on port: '+ port));
web.config
<?xml version="1.0" encoding="utf-8"?>
<!--
This configuration file is required if iisnode is used to run node processes behind
IIS or IIS Express. For more information, visit below link
https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config
-->
<configuration>
<system.webServer>
<!-- indicates that the server.js file is a node.js application
to be handled by the iisnode module -->
<webSocket enabled="false" />
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<!-- Do not interfere with requests for node-inspector debugging -->
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^server.js\/debug[\/]?" />
</rule>
<!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
<rule name="StaticContent">
<action type="Rewrite" url="public{REQUEST_URI}" />
</rule>
<!-- All other URLs are mapped to the node.js site entry point -->
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True" />
</conditions>
<action type="Rewrite" url="server.js" />
</rule>
</rules>
</rewrite>
<security>
<requestFiltering>
<hiddenSegments>
<remove segment="bin" />
</hiddenSegments>
</requestFiltering>
<authorization>
<remove users="*" roles="" verbs="" />
<add accessType="Allow" users="amlgm\cclark, amlgm\tknoob, amlgm\tnakagawa, amlgm\csnyder, amlgm\rcarter" />
</authorization>
</security>
<!-- Make sure error responses are left untouched -->
<httpErrors existingResponse="PassThrough" />
<!-- <httpErrors errorMode="DetailedLocalOnly">
<remove statusCode="401" />
<error statusCode="401" errorMode="Detailed"/>
</httpErrors> -->
</system.webServer>
</configuration>