-1

I need to create proxy rewrite in IIS using ARR

So:

I have 2 servers:

https://server1.com
https://server2.com

Now in each of them i have virtual folder

https://server1.com
    FilesFolder

https://server2.com
    FilesFolder

I saved files in server2

like:

https://server2.com
    FilesFolder
        users-profile
            test.png

Now i need when i open chrome

https://server1.com/FilesFoler/users-profile/test.png

I want that this request go to

https://server2.com/FilesFoler/users-profile/test.png

Now I did proxy rule for Server 1:

Test 1:

<rules>
                <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                    <match url="(.*)" />
                    <action type="Rewrite" url="https://server2/{C:0}" />
                    <conditions>
                        <add input="{URL}" pattern="/users-profile/.*" />
                    </conditions>
                </rule>
            </rules>

This rule not work if i open url like:

https://server1.com/FilesFoler/users-profile/test.png

But work wjen I open: https://server1.com/FilesFoler/FilesFoler/users-profile/test.png

Then i try another rule;

Test 2

 <rules>
                <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                    <match url="(.*)" />
                    <action type="Rewrite" url="https://server2/FilesFolder/{C:0}" />
                    <conditions>
                        <add input="{URL}" pattern="/users-profile/.*" />
                    </conditions>
                </rule>
            </rules>

But when I open https://server1.com/FilesFoler/users-profile/test.png This still not work.....

What wrong here?

David Abaev
  • 690
  • 5
  • 22

1 Answers1

0

In this case, if your request is https://server1.com/FilesFoler/users-profile/test.png.

When IIS handle the condition pattern <add input="{URL}" pattern="/users-profile/.*" />.

Then your {C:0} should be users-profile/test.png. So the request will be rewritten to

https://server2/users-profile/test.png

instead of

https://server2.com/FilesFoler/users-profile/test.png.

So please replace [C:0} to {R:1} or {R:0}

   <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                    <match url="(.*)" />
                    <action type="Rewrite" url="https://server2/{R:0}" />
                    <conditions>
                        <add input="{URL}" pattern="/users-profile/.*" />
                    </conditions>
                </rule>

Since you are not using ssl-offloading for server2. Please ensure server2 is using a trusted certificate, otherwise, SSL handshake between ARR and Server2 may fail.

If you get 404 error, please remember to enable Proxy setting in IIS manager->server node->application request routing cache-> Enable proxy.

Jokies Ding
  • 3,374
  • 1
  • 5
  • 10