Reputation: 213
I am aware that we can use rewrites in azure application gateway to rewrite your url, request/response headers. But How can we modify our host based on a condition.
I have already tried rewriting Header Host but Appgw gives me error: that you can't do it as you have backend action associated with this
Upvotes: 0
Views: 1369
Reputation: 5570
I have already tried rewriting Header Host but Appgw gives me error: that you can't do it as you have backend action associated with this.
Note that Azure Application gateway rewrite rule as limitation - Rewrites aren't supported when the application gateway is configured to redirect the requests or to show a custom error page. Refer this MsDoc.
If you have a backend action associated with the Host header, you can try using the rewrite rule to modify the Location header instead. You can set the host name in the Location header to the application gateway.
In Application gateway, create rewrite rule set and add if condition with regular expression pattern as per your requirement I have added variable with header and pattern to match like below (https?):\/\/.*azurewebsites.net(.*)$
Then in action type select set
for action type and respose
in response type
This value will replace azurewebsites.net
with google.com
in the location header.
Reference:
Rewrite HTTP headers and URL with Azure Application Gateway | Microsoft Learn
Upvotes: 0