Reputation: 3331
I have a very simple nodejs https server that I'm trying to get working with iisnode
, but it doesn't appear that the node process is starting, so I get a 500 error when I try to navigate to it.
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const fs = require('fs');
const cors = require('cors');
var https = require('https');
app.use(bodyParser.json());
app.use(cors());
app.get('/', function (req, res) {
res.send('Hello World!')
});
var secureServer = https.createServer({
key: fs.readFileSync('private.key'),
cert: fs.readFileSync('certificate.pem')
}, app).listen(process.env.PORT || 3443, function () {
console.log('Secure Server listening on port 3443');
});
This application starts fine if I do node server.js, but when I try to rely on the node virtual directory that was set up by the setupsamples.bat
script, it doesn't seem to work. My Web.config also looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode" />
</handlers>
<modules>
<remove name="MyAuthModule" />
</modules>
<security>
<authorization>
<add accessType="Allow" users="?" />
</authorization>
</security>
<rewrite>
<rules>
<rule name="mcServer">
<match url="mcServer/*" />
<action type="Rewrite" url="server.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
MyAuthModule
is a custom authentication module that was set up for me in my environment, so if I don't have that remove statement, I get an error about the module not existing.
I placed server.js
, the Web.config displayed above, and the certificate files into its own mcServer
directory in iisnode/www
directory that was created by running the setupsample.bat script. When I navigate to https://myUrl/node/mcServer
, I get a 500 error, but if I navigate to https://myUrl/node
, it displays the different apps that are available, and like I said, the node process is not running, so I think that's part of the 500 error that I get.
It's also good to note that I installed the url rewrite module, so that shouldn't be the issue, and helloworld/readme.htm
, but once again, I'm assuming this is because node hasn't started.
I must be doing something totally stupid, but I cannot figure it out.
Upvotes: 0
Views: 1541
Reputation: 3331
There were several things that I had wrong:
npm link <module_name>
, but that apparently doesn't work with IIS, so I did npm install
for all of the modules that I neededmatch url
should be /*
, not mcServer/*
app.get('/mcServer/'
Upvotes: 1