OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How to successfully run node server with IIS?

  • Thread starter Thread starter Loizos Vasileiou
  • Start date Start date
L

Loizos Vasileiou

Guest
So I have a web application with ISS-10, running on wwww.mymindmapper.com and listening on port:80. I have two simple pages (login.html & register.html). Here is what it looks like: https://i.sstatic.net/hLLfU.jpg

My main objective is to try and figure out how to create a Node JS server (port: 81) with my webApp on IIS that is on port: 80. Here is my app.js file:

Code:
//USE `nodemon scripts/server.js` on Terminal to refresh Node Server on File Save.
//USE 'pm2 start scripts/server.js' on Terminal to start pm2 for IIS ??????????????????

//Import Node JS modules
const express = require("express");
const morgan = require("morgan"); 
const mysql = require("mysql");

//Create a new instance of express()
const app = express();

//GET INFORMATION ABOUT THE SERVER REQUESTS (OS, Browser, time, Internal Errors, Status Codes)
app.use(morgan('short')); //'short', 'combined'

//Require files from folder public     (THIS CONTAINS ALL .html files inc. login.html and register.html)
app.use(express.static('./public'));

//Listen on PORT:80 with a callback function
app.listen(81, ()=>{
    console.log("Server running on port 81");
});

Please note that when i make requests through terminal on Visual Studio Code, everything works as expected. Data can be added/deleted from my database. (I use XAMPP - Apache listens on port:80 and mMySQL listens on port:3306).

I have read somewhere that this can be solved with a Reverse Proxy on IIS. However this doesn't seems to work. Also when the reverse-proxy configuration is made the following error occurs when i refresh the page.

Reverse proxy configuration

enter image description here

<p>So I have a web application with <code>ISS-10</code>, running on <code>wwww.mymindmapper.com</code> and listening on <code>port:80</code>. I have two simple pages (<code>login.html</code> & <code>register.html</code>). Here is what it looks like: <a href="https://i.sstatic.net/hLLfU.jpg" rel="nofollow noreferrer">https://i.sstatic.net/hLLfU.jpg</a></p>

<p>My main objective is to try and figure out how to create a Node JS server (<code>port: 81</code>) with my webApp on IIS that is on <code>port: 80</code>. Here is my <code>app.js</code> file:</p>

<pre><code>//USE `nodemon scripts/server.js` on Terminal to refresh Node Server on File Save.
//USE 'pm2 start scripts/server.js' on Terminal to start pm2 for IIS ??????????????????

//Import Node JS modules
const express = require("express");
const morgan = require("morgan");
const mysql = require("mysql");

//Create a new instance of express()
const app = express();

//GET INFORMATION ABOUT THE SERVER REQUESTS (OS, Browser, time, Internal Errors, Status Codes)
app.use(morgan('short')); //'short', 'combined'

//Require files from folder public (THIS CONTAINS ALL .html files inc. login.html and register.html)
app.use(express.static('./public'));

//Listen on PORT:80 with a callback function
app.listen(81, ()=>{
console.log("Server running on port 81");
});

</code></pre>

<p>Please note that when i make requests through terminal on Visual Studio Code, everything works as expected. Data can be added/deleted from my database. (I use <code>XAMPP</code> - Apache listens on <code>port:80</code> and mMySQL listens on <code>port:3306</code>).</p>

<p>I have read somewhere that this can be solved with a <code>Reverse Proxy</code> on IIS. However this doesn't seems to work. Also when the reverse-proxy configuration is made the following error occurs when i refresh the page.</p>

<p><a href="https://i.sstatic.net/X5bkJ.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/X5bkJ.png" alt="Reverse proxy configuration"></a></p>

<p><a href="https://i.sstatic.net/49Eqe.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/49Eqe.png" alt="enter image description here"></a></p>
 

Latest posts

Top