Skip to content

How to use IIS as a reverse proxy for node js server

Last updated on July 6, 2023

To use IIS (Internet Information Services) as a reverse proxy for a Node.js server, you can follow these steps:

  1. Install IIS on your Windows machine:
    • Open the “Control Panel” and navigate to “Programs” or “Programs and Features.”
    • Click on “Turn Windows features on or off.”
    • Find and select “Internet Information Services” and click “OK” to install it.
  2. Enable the necessary IIS modules:
    • Open the “Control Panel” and navigate to “Programs” or “Programs and Features.”
    • Click on “Turn Windows features on or off.”
    • Expand “Internet Information Services” and select the following modules:
      • Common HTTP Features -> HTTP Redirection
      • Application Development -> WebSocket Protocol
      • Security -> Request Filtering
      • Application Request Routing (ARR)
      • URL Rewrite
    • Click “OK” to enable the selected modules. Windows will install the required components.
  3. Configure your Node.js server to listen on a specific port (e.g., 3000). Make sure your Node.js server is running and accessible at the specified port.
  4. Open the IIS Manager:
    • Press “Windows Key + R” to open the Run dialog.
    • Type “inetmgr” and press “Enter” to open the IIS Manager.
  5. Create a new website in IIS:
    • In the IIS Manager, select your server’s hostname in the Connections pane on the left side.
    • Double-click on the “Server Certificates” feature and create or import an SSL certificate if you want to use HTTPS (optional).
    • Right-click on “Sites” and choose “Add Website”.
    • Provide a “Site name” and set the “Physical path” to the root directory of your Node.js application.
    • Set the “Binding” to the appropriate hostname, port, and optionally choose the SSL certificate for HTTPS.
    • Click “OK” to create the website.
  6. Configure the URL Rewrite and ARR:
    • In the IIS Manager, select the website you created in the previous step.
    • Double-click on the “URL Rewrite” feature.
    • Click “Add Rule(s)” in the Actions pane on the right side.
    • Choose “Reverse Proxy” as the rule template and click “OK”.
    • Configure the following settings:
      • Reverse Proxy:
        • Inbound rules: <your-node-app-host>:<your-node-app-port>/*
        • Backend server: http://localhost:<your-node-app-port>/*
      • Proxy:
        • Preserve host headers: Checked
        • ARR caching: None
        • Routing rules: None
    • Click “Apply” to save the configuration.
  7. Test the reverse proxy:
    • Open a web browser and navigate to the hostname or IP address associated with your IIS website.
    • If everything is configured correctly, the request should be forwarded to your Node.js server, and you should see the response from your Node.js application.

By following these steps, you can set up IIS as a reverse proxy for your Node.js server, allowing IIS to handle incoming requests and forward them to your Node.js application.

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments