This topic describes how to configure HTTP Strict Transport Security (HSTS). After HSTS is configured, clients such as browsers can establish only HTTPS connections to CDN edge nodes. HSTS protects requests from hijacking.
Prerequisites
Background information
HSTS is a policy mechanism that allows websites to accept only HTTPS connections. Websites can use HSTS to demand that clients such as browsers must use HTTPS. All HTTP requests and untrusted SSL certificates are rejected. HSTS prevents man-in-the-middle (MITM) attacks during the first visits from clients.
If HSTS is disabled and HTTPS is enabled on CDN edge nodes, HTTP requests sent to the edge nodes are redirected to HTTPS when 301 redirection or 302 redirection is enabled. The first HTTP request sent from a client to an edge node may be hijacked or tampered with. Hijacking and tampering raise security issues. If HSTS is enabled, clients can access the origin server only over HTTPS. This prevents requests from hijacking and tampering.
Strict-Transport-Security:max-age=expireTime [;includeSubDomains] [;preload]
. The following table describes the parameters in the header.
Parameter | Description |
---|---|
max-age | The time-to-live (TTL) of the HSTS header. Unit: seconds. |
includeSubDomains | Optional. If this parameter is set, the preceding parameters apply to all subdomains of the domain name. |
preload | Optional. This parameter allows you to add the domain name to the HSTS preloaded list of the browser. |
Limits
- Before HSTS takes effect, you can Configure URL redirection to redirect the first HTTP requests from clients to HTTPS through 301 redirection.
- The HSTS response header applies to the responses to HTTPS requests, but does not apply to the responses to HTTP requests.
- HSTS applies only to port 443.
- HSTS applies only to domain names. It does not apply to IP addresses.