英文:
HTTP Error 502.2 - Bad Gateway IIS server ,when try to hit backend API from Front end using URL rewrite
问题
我有一个独立的前端应用程序和后端应用程序托管在IIS中
前端应用程序端口为443(HTTPS)
后端应用程序端口为444(HTTPS)在Nodejs中
当我尝试访问后端API https://localhost:444/apis/sample
我能够获得响应
我在前端使用URL重写,当我尝试从前端站点使用反向代理访问后端API时,我收到了这个错误
前端URL https://localhost/apis/sample
我使用IIS创建的自签名证书,用于将Nodejs后端作为https
<rewrite>
<rules>
<rule name="ReverseProxyInboundRule1" enabled="true" stopProcessing="true">
<match url="^(apis/)(.*)" />
<action type="Rewrite" url="https://127.0.0.1:444/{R:0}" appendQueryString="true" logRewrittenUrl="true" />
</rule>
<rule name="Angular Refresh Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
英文:
I have a separate Front end application and backend application hosted in IIS
Front end application Port is 443(HTTPS)
Backend Application Port is 444(HTTPS) is in Nodejs
When I try to hit the backend API https://localhost:444/apis/sample
I am able to get the response
I am using URL rewrite in Front end and when I try to hit the backend api from front end site using Reverse Proxy I am getting this Error
Front end URL https://localhost/apis/sample
I am using self-signed certificate created using IIS, for making Nodejs backend as https
<rewrite>
<rules>
<rule name="ReverseProxyInboundRule1" enabled="true" stopProcessing="true">
<match url="^(apis/)(.*)" />
<action type="Rewrite" url="https://127.0.0.1:444/{R:0}" appendQueryString="true" logRewrittenUrl="true" />
</rule>
<rule name="Angular Refresh Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
答案1
得分: 1
502.3错误有许多原因,为了进行故障排除,您可以通过netsh启用WinHTTP跟踪。运行以下命令以启用跟踪:
netsh winhttp set tracing trace-file-prefix="C:\Temp\WinHttpLog" level=verbose format=hex state=enabled
然后重新启动应用程序池以开始记录日志。要禁用跟踪,运行以下命令:
netsh winhttp set tracing state=disabled
您将在C:\Temp目录中找到一个名为WinHttpLog-w3wp.exe-<pid>.<datetime>.log
的日志文件。打开此文件,您将能够查看ARR在生成代理请求以发送到内容节点时提交给WinHTTP的详细信息。您需要在此文件中搜索Failed Request Tracing日志中提到的错误。
有关更多信息,您可以参考此链接:TROUBLESHOOTING ARR 502.3 ERRORS.
英文:
There are many reasons for 502.3 error, for troubleshooting, you can enable WinHTTP tracing via netsh. Run this command to enable tracing:
netsh winhttp set tracing trace-file-prefix="C:\Temp\WinHttpLog" level=verbose format=hex state=enabled
Then recycle the application pool to start logging. To disable tracing, run this command:
netsh winhttp set tracing state=disabled
You will find a log file in the C:\Temp directory named WinHttpLog-w3wp.exe-<pid>.<datetime>.log
. Open this file and you will be able to see details of what ARR submitted to WinHTTP when generating the proxied request to send to the content node. You’ll want to search this file for the error mentioned in the Failed Request Tracing log.
For more information you can refer to this link: TROUBLESHOOTING ARR 502.3 ERRORS.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论