Review Web App HTTPS redirection

Enable HTTPS redirection and configure clients to use encrypted URLs from the start.

Description

Set properties.httpsOnly to true on the Azure App Service site to redirect HTTP requests to HTTPS.

Potential impact

The first HTTP request can expose login data or session cookies before the redirect takes effect.

Remediation

Change links, clients and scripts to use HTTPS from the start. Enable certificate validation, appropriate HSTS and Secure cookies. If a CDN or proxy is involved, check every connection through to the app. Test both the redirect and final HTTPS connection with a request that carries no sensitive information.

Examples

Supply your app name, Region and the App Service plan required for deployment.

Before

bicep
resource webSite 'Microsoft.Web/sites@2020-12-01' = {
  name: 'webSite'
  location: 'location1'
  tags: {}
  properties: {
    enabled: true
  }
}

The first excerpt omits httpsOnly. Check the live app and any redirect at the proxy.

After

bicep
resource webSite 'Microsoft.Web/sites@2020-12-01' = {
  name: 'webSite'
  location: 'location1'
  tags: {}
  properties: {
    enabled: true
    httpsOnly: true
  }
}

The second enables the App Service HTTPS redirect on the same site.

References