DEV Community

Segun Olaiya
Segun Olaiya

Posted on

Deploying Node/Express app on a Windows Server

I had this small side project I worked on for a client over a weekend, it was a simple express API.
Everything worked well and good until it was time to deploy! This was my conversation with the client..

Me: Cool so the app is ready, can you send me your staging server details so i can deploy for you?
Client: Yea cool, i will send you an RDP credentials to our Windows VM
Me: Wait what?

Ok jokes apart, lets get straight into it!

Before we continue, you should have a basic knowledge of Setting up a simple Express App and using Nodemon or any other Node Process manager.

To speed things up, i have setup a simple express app with a single endpoint for this demo, please note that the target is not necessarily an introduction to Express but how to deploy an Express based app on Windows.

GitHub logo massivebrains / express-demo

An Express Demo App


An Express Demo App

You can clone the repo to follow along.

Setup the express app on the server

If you are using the sample app that was cloned, run yarn and then yarn start . The app should now start with nodemon. Assuming you have not changed the default port, head over to your browser at http://localhost:3000 . you should see the sample json response as below

  status: true,
  data: "Api Works"
Enter fullscreen mode Exit fullscreen mode

Setting up a proxy with IIS

Now the app is running locally but not available outside the server. What we want is for the public to be able to reach the app at where is our domain.

Step 1

Search and open Internet Information Services (IIS)

Step 2

Expand Sites -> Default Web Site

Right click on Default Web Site and select Add Application

Adding a URL rewrite

Make sure the newly created app is selected under the Default Web Site, click on URL Rewrite from the IIS dashboard on the right.

On the right, click on Add Rule(s) and then select Reverse Proxy

On the inbound rules dialogue box, enter localhost:3000 as illustrated below.

If you changed the port number where the express app is currently running, make sure you use localhost:{port_number}

Click on OK after this.

Now head over to a browser (outside your server) and try to access (where is your actual domain name.

Top comments (2)

joedotnot profile image

Wait, you are going to run the node app in a console (cmd line) window, using yarn / nodemon - Do you intend to be logged onto the server VM permanently ?!

nicoserranop profile image
Nico Serrano

You could use pm2 to avoid having the console / session open permanently