0

let's say the Application gateway receives a request http://contoso.com/images and is configured to forward that to backendserver.contoso.com. Using a path based routing rule (/images/* for example).

I want the application gateway not to retain the /images path in the request URL. I need this to be truncated, in which case the request will simply be http://contoso.com/. Any path after the /images will remain intact though.

Is it possible? Any help/clue is greatly appreciated.

Moim
  • 486
  • 1
  • 8
  • 23
  • I have aslo asked the same question on MSDN (see last comment) here: https://learn.microsoft.com/en-us/azure/application-gateway/application-gateway-create-url-route-arm-ps. Please give me a hint if anybody encountered any workaround to this. – Moim Jan 08 '18 at 12:22

2 Answers2

2

Yes you could do this today with PowerShell/CLI. In the backend http setting associated with the pool, please specify a -Path parameter. For example -

Add-AzureRmApplicationGatewayBackendHttpSettings -Path "/" -Name setting1 -Port 80 -Protocol Http -CookieBasedAffinity Disabled 

When -Path is not specified at all, incoming request is routed to backend as is - which is the default behavior. When specified as "/" it removes the matching path from URI. If specified as a non-null value, then the specified value is used in place of matched path.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
amsriva-msft
  • 319
  • 1
  • 5
0

Amsrivas and Stephens answer is correct, but the poweshell CLI seems to have changed, at least @ version 5.5.0 and now you have to perfrom this opperation using the following commands:

# Get gateway object    
$AppGw = Get-AzureRmApplicationGateway -Name "YOUR GATEWAY NAME" -ResourceGroupName "YOUR GATEWAY RESOURCE GROUP"
# Show current settings
Get-AzureRmApplicationGatewayBackendHttpSettings -ApplicationGateway $AppGw
# Set path on local object (other values are whatever you want)
Set-AzureRmApplicationGatewayBackendHttpSettings -ApplicationGateway $AppGw -Name "YOUR SETTING NAME" -Port "80" -Protocol "Http" -CookieBasedAffinity "Disabled" -RequestTimeout 30 -Path "/"
# Commit changes back to Azure
$UpdatedAppGw = Set-AzureRmApplicationGateway -ApplicationGateway $AppGw
# Show new settings as applied in Azure
Get-AzureRmApplicationGatewayBackendHttpSettings -ApplicationGateway $UpdatedAppGw
JohnB
  • 451
  • 5
  • 7