question

SilverLu-5410 avatar image
0 Votes"
SilverLu-5410 asked BruceZhang-MSFT edited

URL rewrite error

Scenario:
Proxy server : domain name : go.ABC.com
server1: domain name: first.ABC.com created website is url: https://first.ABC.com/test
server2: domain name : second.ABC.com created website is url: https://second.ABC.com/check

on Proxy server: created two website "go.ABC.com/test" and "go.ABC.com/check" - enabled rewrite rule on "test"

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="first" enabled="true" stopProcessing="true">
<match url=".*" ignoreCase="true" />
<action type="Rewrite" url="https://first.ABC.com/test/{R:0}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

Enabled rewrite rule on "check"

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="Check" enabled="true" stopProcessing="true">
<match url=".*" ignoreCase="true" />
<action type="Rewrite" url="https://second.ABC.com/check/{R:0}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

Test https://go.ABC.com/test is working , it showed webpage on https://first.ABC.com/test
Test https://go.ABC.com/check is not working , it showed 502 - Web server received an invalid response while acting as a gateway or proxy server.

I think the rewrite rule is OK, as the first one is woking. but for another server, what configuration will cause this error

windows-server-iis
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @SilverLu-5410 ,

In theory, the rule is OK and there is no problem in proxy server because the error is 502.

You need to use failed request tracing to troubleshoot rewrite rule in proxy server so that we can make sure if the rule is ok. If the rewrite rule is ok, you will see rewrite success and proxy server has send xxx bytes to server2 but receive 0 bytes from server2. By the way, check the sub status code in failed request tracing log.

Then enable failed request tracing on server2. Check if it received the request from proxy server and what the url is, then check how IIS handle the request.

Using Failed Request Tracing to Trace Rewrite Rules
Using Failed Request Tracing Rules to Troubleshoot Application Request Routing


0 Votes 0 ·

0 Answers