Host a Node.js /w Next.js Application

Intro

Running a Next.js app on a Windows Server with IIS (Internet Information Services) so it's publicly accessible requires a few steps, since IIS is not built to directly run Node.js apps. But you can do it by using a reverse proxy to forward IIS requests to your Next.js app running on a local port.


Step 1: Install Node.js on Windows Server

  1. Go to https://nodejs.org/ and download the LTS version.

  2. Install it and verify with:

    node -v
    npm -v

Step 2: Copy or Build Your Next.js App

  • Copy your app to the Windows Server.

  • Navigate to the app folder and run:

npm install
npm run build
npm run start
  • This starts your app, likely on http://localhost:3000.

set PORT=5000 && npm run start

Step 3: Set Up IIS as a Reverse Proxy

To make the app accessible via IIS:

Install URL Rewrite & ARR (Application Request Routing)

  • URL Rewrite Module

  • ARR

Enable Proxy in ARR

  • Open IIS Manager

  • Click on the server name (root node)

  • Open Application Request Routing Cache

  • On the right-hand side, click "Server Proxy Settings"

  • Check "Enable proxy" and click Apply

Create a Website in IIS

  • Point the site root to any folder (even if empty—it won’t serve files directly).

  • Assign a host name (e.g., myapp.mydomain.com) or use a port binding.

Add URL Rewrite Rule

  • Select the website in IIS

  • Open URL Rewrite

  • Click "Add Rules" → Choose "Reverse Proxy"

  • Set the destination as:

http://localhost:3000

Step 4: Make Sure the App Is Running Continuously

IIS won’t run the Node app directly, so use one of these tools:

  • PM2 (recommended for production):

npm install pm2 -g
pm2 start npm --name "nextjs-app" -- run start
pm2 save
pm2 startup
  • NSSM (Non-Sucking Service Manager) to run it as a Windows Service


Step 5: Test Public Access

  • Make sure your domain (e.g., myapp.mydomain.com) points to your Windows server’s IP.

  • Open a browser and visit the domain — you should see your Next.js app!


Extra Notes


REFERENCES

Last updated

Was this helpful?