---
title: "Make browsers always use HTTPS · Agent Wranglers"
url: https://agentwranglers.se/playbook/application-security/browser-security-headers/hsts
id: APS-23
level: Required
risk: takeover
updated: 2026-10-27
build: a2a6bdfed830
tokens: 744
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Make browsers always use HTTPS

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Browser security headers](https://agentwranglers.se/playbook/application-security/browser-security-headers.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-27.

- ID: APS-23
- Level: Required
- Chapter: [Browser security headers](https://agentwranglers.se/playbook/application-security/browser-security-headers.md)
- Rule: Send `Strict-Transport-Security` so browsers always use HTTPS. Give it a long `max-age` (at least a year) and `includeSubDomains`, on HTTPS responses only.
- Check: `curl -sI https://example.com/` and a missing page both show the header with `max-age` of at least 31536000. `curl -sI http://example.com/` shows no such header.
- Risk: An account or system taken over
- How: Start with a short `max-age`, such as 300 seconds. Once nothing breaks, set it to 63072000, which is two years. Add `includeSubDomains` once every subdomain serves HTTPS. Send the header from the web server with `always`, so error responses carry it too. Add `preload` and submit the domain to the browser preload list only when you are sure, because leaving the list takes months. Encrypt every other connection too, as [Encrypt data on the wire and on disk](https://agentwranglers.se/playbook/application-security/cryptography-and-keys/encrypt-data.md) says.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### HTTP example

```http
HTTP/2 200
strict-transport-security: max-age=63072000; includeSubDomains
```

### nginx example

```nginx
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" always;
```

## Sources

- [RFC 6797: HTTP Strict Transport Security](https://www.rfc-editor.org/rfc/rfc6797)

## Related rules

- APS-54 [Encrypt data on the wire and on disk](https://agentwranglers.se/playbook/application-security/cryptography-and-keys/encrypt-data.md) in Application security

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/application-security/browser-security-headers/hsts">Agent Wranglers application security playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Send the security headers as one set](https://agentwranglers.se/playbook/application-security/browser-security-headers/header-set.md)
- Next: [Load nothing over plain HTTP](https://agentwranglers.se/playbook/application-security/browser-security-headers/mixed-content.md)
- [Browser security headers](https://agentwranglers.se/playbook/application-security/browser-security-headers.md)
