How To Enforce HTTP Strict Transport Security (HSTS) On A Virtual Server
How To Enforce HTTP Strict Transport Security (HSTS) On A Virtual Server
Support Solution
Description
Configuring HTTP Strict Transport Security (HSTS) on an LTM virtual server. You should consider using this
procedure under the following conditions:
You want to protect against HTTP downgrade attacks (SSL stripping attacks) by requiring all traffic to
use HTTPS.
You want to protect against mixed content on your website. HSTS automatically upgrades fetches to
HTTPS in situations where a domain has mixed content.
You can configure the BIG-IP system to insert an HTTP Response 'Strict-Transport-Security' response header
to enforce HTTP Strict Transport Security. In versions prior to BIG-IP 12.0.0, this is achieved through using a
custom iRule. Starting in BIG-IP 12.0.0, you can create a custom HTTP Profile with 'HTTP Strict Transport
Security' Enabled.
Environment
The virtual server in question must have a Client SSL Profile applied.
Cause
None
Recommended Actions
Configuring HSTS using the BIG-IP Configuration utility (BIG-IP 12.0.0 and later)
Configuring HSTS using the BIG-IP Configuration utility (BIG-IP prior to 12.0.0)
Con guring HSTS using the BIG-IP Con guration utility (BIG-IP 12.0.0 and later)
The following procedure allows you to enable HSTS.
https://support.f5.com/csp/article/K68657325 1/3
09/04/2021 How to enforce HTTP Strict Transport Security (HSTS) on a virtual server
Impact of procedure: Performing the following procedure will force HSTS-compatible clients to request only
HTTPS pages from your website. If your site requires non-HTTPS content to be served, some resources may
become unavailable.
9. Optional: Check the Enabled box for Preload to include ; preload in the Strict-Transport-Security HTTP
Response Header.
10. Click Update.
11. Associate the HTTP profile with the virtual server.
Con guring HSTS using the BIG-IP Con guration utility (BIG-IP prior to 12.0.0)
Prior to BIG-IP 12.0.0, you could not configure HSTS in an HTTP Profile. This functionality can be achieved
only through using an iRule.
Impact of procedure: Performing the following procedure forces HSTS-Compatible clients to request only
HTTPS pages from your website. If your site requires non-HTTPS content to be served, some resources may
become unavailable.
For example: The following iRule responds with a Strict-Transport-Security Header with a Max
Age of 16070400 seconds. Apply to all Sub Domains and add the HSTS host and its subdomains
to the browser's HSTS preload list of sites that are considered HTTPS only.
when HTTP_RESPONSE_RELEASE {
if { !([HTTP::header exists "Strict-Transport-Security"])} {
HTTP::header insert "Strict-Transport-Security" "max-age=16070400;
includeSubdomains; preload"
}
}
Example: The following iRule will respond with a Strict-Transport-Security HTTP Header with a
Max Age of 16070400 seconds and apply to all Sub Domains:
when HTTP_RESPONSE_RELEASE {
if { !([HTTP::header exists "Strict-Transport-Security"])} {
HTTP::header insert "Strict-Transport-Security" "max-age=16070400;
includeSubdomains"
}
}
https://support.f5.com/csp/article/K68657325 2/3
09/04/2021 How to enforce HTTP Strict Transport Security (HSTS) on a virtual server
6. Click Finished.
Additional Information
None
Related Content
K40243113: Overview of the HTTP profile
K30114265: Configuring HTTP 301 redirect to preserve HSTS headers
F5 Support engineers who work directly with customers to resolve issues create this content. Support Solution
articles give you fast access to mitigation, workaround, or troubleshooting suggestions.
Applies to:
https://support.f5.com/csp/article/K68657325 3/3