Strapi with IIS and Reverse Proxy

System Information
  • Strapi Version: 4
  • Operating System: Windows Server 2019
  • Database: PostgresSQL
  • Node Version: 20.14.0
  • NPM Version: 10.7.0

We have a Strapi app that needs to be hosted on windows server 2019 using pm2 and IIS. Things are fine with pm2 and we were able to run and access the app on localhost:1377.

However, when configuring a Reverse Proxy to be able to access the desired bindings we keep facing the below error:
HTTP Error 502.3 - Bad Gateway

According to several resources, below is the web.config and server.js:

const strapi = require('@strapi/strapi');


<?xml version="1.0" encoding="UTF-8"?>
                <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions logicalGrouping="MatchAny">
                        <add input="{HTTP_X_FORWARDED_FOR}" pattern="^$" />
                        <add input="{HTTP_HOST}" pattern="^localhost$" negate="true" />          
                    <action type="Rewrite" url="http://localhost:1377/{R:1}" />
            <reverseProxy enabled="true" />
                <add path="*">
                        <add provider="ASP" verbosity="Verbose" />
                        <add provider="ASPNET" areas="Infrastructure,Module,Page,AppServices" verbosity="Verbose" />
                        <add provider="ISAPI Extension" verbosity="Verbose" />
                        <add provider="WWW Server" areas="Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module,FastCGI,WebSocket,RequestRouting" verbosity="Verbose" />
                    <failureDefinitions statusCodes="400,502" />

Thanks in advance