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:
server.js:
const strapi = require('@strapi/strapi');
strapi().start();
web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<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" />
</conditions>
<action type="Rewrite" url="http://localhost:1377/{R:1}" />
</rule>
</rules>
</rewrite>
<proxy>
<reverseProxy enabled="true" />
</proxy>
<tracing>
<traceFailedRequests>
<add path="*">
<traceAreas>
<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" />
</traceAreas>
<failureDefinitions statusCodes="400,502" />
</add>
</traceFailedRequests>
</tracing>
</system.webServer>
</configuration>