3

I have application gateway sitting in front of Azure App Service (Standard) . I have .Net Core 3.1 basic MVC web app hosted on App Service.

Problem

The problem is when I hit Application Gateway URL (default hostname) it redirects the request to Azure App Service URL which is not what I want. I want APP gateway to proxy the request but not actually redirect me to the Azure App Service.

Possible Cause:

I believe it's a known thing. Redirection is possibly being caused because of Location Header in response as mentioned here Redirection Issue in Documentation.

Steps taken:

I have tried to rewrite the URL as suggested here Rewrite Response in official documentation however when I rewrite the response header It not working. Some time I don't get the response and other times It gets into Redirection Loop. Please note I am not using custom domain as suggested in the document but default App Gateway host name (xx.australiaeast.cloudapp.azure.com)

I have tried following header values

{http_resp_Location_1}://{var_host}{http_resp_Location_2}

http://{var_host}{http_resp_Location_2}

Any help/guidance is highly appreciated.

Imran

Imran Arshad
  • 3,794
  • 2
  • 22
  • 27

1 Answers1

1

If you are using AGW v2, then here is the solution.

You can create a rewrite rule condition with specific app service backend as follows:

    {
        "ruleSequence": 101,
        "conditions": [
            {
                "variable": "http_resp_Location",
                "pattern": "(https?):\\/\\/test.abc.appserviceenvironment.net(.*)$",
                "ignoreCase": true,
                "negate": false
            }
        ],
        "name": "test-rewrite-rule",
        "actionSet": {
            "requestHeaderConfigurations": [],
            "responseHeaderConfigurations": [
                {
                    "headerName": "Location",
                    "headerValue": "{http_resp_Location_1}://contoso.com{http_resp_Location_2}"
                }
            ]
        }
    }
gurkan
  • 884
  • 4
  • 16
  • 25
  • 1
    Thank you @smita sukumaran . From config it looks like you are referring to ASE ? I am using Standard App Service plan, you think its going to work with that ? – Imran Arshad Jun 04 '21 at 03:44