Skip to content

Commit

Permalink
Merge pull request #5599 from dfe-analytical-services/EES-5820-fix-tr…
Browse files Browse the repository at this point in the history
…ailing-slash-redirects-in-static-webapp

EES-5820 - rewriting "Location" response headers to replace static webapp FQDN with public FQDN
  • Loading branch information
duncan-at-hiveit authored Feb 17, 2025
2 parents afae656 + 41454ae commit 3eb83d3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
18 changes: 18 additions & 0 deletions infrastructure/templates/public-api/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,24 @@ module appGatewayModule 'application/shared/appGateway.bicep' = if (deployContai
}
}
}
{
name: 'replace-docs-backend-fqdn-with-public-docs-url'
conditions: [
{
variable: 'http_resp_Location'
pattern: 'https://${docsModule.outputs.appFqdn}/(.*)'
ignoreCase: true
}
]
actionSet: {
responseHeaderConfigurations: [
{
headerName: 'Location'
headerValue: '${publicUrls.publicApi}/docs/{http_resp_Location_1}'
}
]
}
}
]
}
]
Expand Down
16 changes: 14 additions & 2 deletions infrastructure/templates/public-api/types.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -220,21 +220,33 @@ type AppGatewayRewriteCondition = {
@export()
type AppGatewayRewriteActionSet = {
@description('Rewrite config for the URL')
urlConfiguration: AppGatewayRewriteUrlConfig
urlConfiguration: AppGatewayRewriteUrlConfig?

@description('Rewrite config for the URL')
responseHeaderConfigurations: AppGatewayRewriteHeaderConfig[]?
}

@export()
type AppGatewayRewriteUrlConfig = {
@description('The path after it has been rewritten. Can contain variables from other parts of the request')
modifiedPath: string?

@description('The query string after it has been rewritten. Can contain variables from other parts of the request')
@description('The query string after it has been rewritten. Can contain variables from other parts of the original request')
modifiedQueryString: string?

@description('Re-evaluate any associated URL path maps with the rewritten path. Defaults to false')
reroute: bool?
}

@export()
type AppGatewayRewriteHeaderConfig = {
@description('The HTTP header to inspect')
headerName: string

@description('The header value after it has been rewritten. Can contain variables from other parts of the original header')
headerValue: string
}

// This is not an exhaustive list. For a list of available operators, see:
// https://learn.microsoft.com/en-us/azure/templates/microsoft.network/applicationgatewaywebapplicationfirewallpolicies?pivots=deployment-language-bicep#matchcondition
type AppGatewayFirewallPolicyCustomRuleOperator =
Expand Down

0 comments on commit 3eb83d3

Please sign in to comment.