HSTS: HTTP Strict Transport Security dla SEO
co HSTS actually robi, the Strict-Transport-Security header syntax (max-age, includeSubDomains, preload), the przeglądarka-tylko internal redirect crawlers nigdy see, why it doesn't zastępować twój 301s, i how preload może lock you in — z Patrick Stox.
Języki
1 sygnał dowodowy na tej stronie
- Powiązane działające narzędzieHTTP Header Checker
HSTS (HTTP Strict Transport Security) jest a Strict-Transport-Security nagłówek odpowiedzi — honored tylko gdy it arrives ponad a secure connection — że tells a przeglądarka to zawsze używać HTTPS dla twój domain going forward, closing the insecure gap że a new visitor's pierwszy żądanie nadal makes ponad HTTP przed twój 301 fires. It's a przeglądarka-warstwa, per-client polityka on top of twój serwer-side redirects, nie a replacement: RFC 6797 ma the przeglądarka rewrite the URI to HTTPS internally przed dowolny żądanie goes out (często shown as an internal 307-style redirect, though the RFC doesn't mandate a specific kod stanu), so no serwer ever sees the HTTP form i crawlers nadal need twój rzeczywisty 301 to zrozum move i carry link equity. The header ma three directives — max-age (required), includeSubDomains, i preload. Preload bakes twój domain do the przeglądarka itself via hstspreload.org (requiring max-age of co najmniej a year, includeSubDomains, i the preload flag) i jest close to irreversible — removal jest a oddzielny submission że takes months to reach użytkownicy. HSTS jest również deliberately unforgiving: a przeglądarka że knows you as an HSTS host będzie trudny-fail z no click-przez if twój certificate ever breaks. So enable it tylko once HTTPS jest genuinely solid w całym każdy subdomain, i treat preload as a one-way door.
TL;DR — HSTS jest a mały instruction twój serwer wysyła przeglądarki że says “always use HTTPS for my site — never plain HTTP.” It plugs a tiny security hole że a normal HTTP→HTTPS redirect leaves otwarty, i it doesn’t hurt SEO. ale it’s strict on purpose: once it’s on, a broken certificate breaks twój witryna z no way dla visitors to click past the ostrzeżenie. Turn it on tylko gdy twój HTTPS setup jest genuinely solid.
co HSTS jest
You już know you powinien być on HTTPS — the encrypted,
padlock version of twój witryna. The normal way to force it jest a redirect: gdy
someone types http://yoursite.com, twój serwer wysyła them a 301 redirect to
https://yoursite.com. że działa, ale there’s a sliver of a gap. że bardzo pierwszy
żądanie — the one przed the redirect fires — nadal goes out ponad insecure HTTP.
An attacker sitting on the same Wi-Fi może pounce in że window.
HSTS — HTTP Strict Transport Security — closes że gap. It’s a short instruction
(a “header”) twój serwer dodaje to jego odpowiedzi — ale tylko the ones served ponad a
genuinely secure connection; the same header sent ponad plain HTTP jest ignored, since
an attacker mógł otherwise inject lub strip it — że tells że one przeglądarka: dla
the następny however-wiele months, nigdy even try HTTP dla ten witryna — go straight to
HTTPS. It’s a polityka każdy przeglądarka learns i sklepy dla itself, nie something że
changes twój serwer. Once a przeglądarka ma seen it, it upgrades http:// links to
https:// wszystkie on jego own, przed anything leaves the urządzenie. Evidence for this claim After receiving HSTS, a browser upgrades future HTTP attempts to HTTPS before sending the request. Scope: MDN documents user-agent enforcement after the header has been learned; first-visit protection requires preload or a prior secure visit. Confidence: high · Verified: MDN: Strict-Transport-Security header
robi HSTS pomagać lub hurt SEO?
Neither, directly. HSTS jest a security i trust funkcja, nie a ranking lever.
It won’t move you up the wyniki — ale done right it won’t hurt you either. The one
thing to understand jest że HSTS jest nie a substitute dla twój redirects. You
nadal need twój rzeczywisty serwer-side 301 redirects z HTTP do HTTPS, ponieważ że’s
co Google i Bing actually see i używać. HSTS działa inside the przeglądarka dla rzeczywisty
człowiek visitors; crawlers don’t rely on it. zachować oba.
The one big ostrzeżenie
HSTS jest deliberately unforgiving. Once a przeglądarka ma “learned” twój witryna jest HTTPS-tylko, it będzie refuse to load the witryna at wszystkie if twój certificate ever expires lub misconfigures — z no “proceed anyway” button. że’s the whole point (it stops attackers z tricking people onto a fake HTTP version), ale it means a lapsed certificate goes z “annoying warning” to “site is down for anyone who’s visited before.”
There’s również a supercharged version called preload że bakes twój domain do the przeglądarka itself. It’s great, ale getting off the preload lista later jest slow i painful — think months. So preload jest a one-way door: tylko walk przez it gdy you’re sure. Evidence for this claim HSTS preload requires at least a one-year max-age, includeSubDomains, and preload; removal can take months to reach users. Scope: The Chromium preload service documents submission and removal behavior; requirements can change and should be rechecked before submission. Confidence: high · Verified: Chromium: HSTS Preload List Submission
Want the header syntax, the przeglądarka-tylko internal redirect crawlers nigdy see, the preload requirements, i the rzeczywisty lockout scenarios? Switch to the Advanced tab.
TL;DR — HSTS jest the
Strict-Transport-Securitynagłówek odpowiedzi, honored tylko gdy a przeglądarka receives it ponad a secure connection, i stored per-client as future polityka dla że host. It closes the “first request problem” a 301 alone leaves otwarty: the initial HTTP żądanie z a new visitor jest insecure until the redirect fires, i że’s the window an SSL-stripping attacker wants. Three directives:max-age(required, seconds),includeSubDomains,preload. gdy a przeglądarka enforces HSTS it rewrites the URI to HTTPS internally, przed dowolny żądanie reaches a serwer — RFC 6797 doesn’t mandate a specific kod stanu dla że rewrite, though narzędzia często surface it as a 307 — so twój serwer-side 301s są nadal mandatory dla wyszukiwarki i link equity; HSTS jest on top of them, nie instead. Preload bakes twój domain do the przeglądarka via hstspreload.org (wymagamax-age≥ 31536000,includeSubDomains, ipreload) i jest close to irreversible — removal jest a oddzielny submission że takes months to reach użytkownicy. i HSTS jest designed to trudny-fail on dowolny cert błąd, so enable it tylko gdy HTTPS jest robust w całym każdy subdomain.
The HTTPS hub introduces HSTS as a przeglądarka-warstwa protection że sits on top of twój 301s. ten strona jest the deep dive: the dokładny header syntax, the internal redirect że trips SEOs up, the preload lista’s near-irreversibility, i the rzeczywisty-world ways HSTS locks people out.
The problem HSTS actually solves: the pierwszy żądanie
Picture a properly migrated witryna. każdy http:// URL 301-redirects to jego https://
twin, the certificate jest prawidłowy, canonicals point to HTTPS. Looks airtight. It isn’t,
quite.
gdy a marka-new visitor types yoursite.com (no scheme) lub clicks an old
http://yoursite.com link, the przeglądarka’s pierwszy żądanie goes out ponad plain HTTP.
twój serwer answers z the 301, i każdy żądanie po że jest secure. ale że
one initial round-trip happened in the jasny — i że’s exactly the window an
SSL-stripping attacker on the same network wants. They intercept the HTTP żądanie,
zachowaj victim on HTTP podczas gdy they proxy HTTPS to twój serwer, i read lub rewrite
everything.
HSTS eliminates że window dla anyone who ma visited przed. web.dev jest bezpośredni
o the mechanism:
“use Strict Transport Security to tell clients they should always connect to your
server using HTTPS, even when following an http:// reference. This defeats attacks
like SSL Stripping, and avoids the round-trip cost of the 301 redirect.”
(web.dev).
że ostatni clause matters dla wydajność too: a returning przeglądarka skips the HTTP→HTTPS
round-trip entirely. Evidence for this claim After receiving HSTS, a browser upgrades future HTTP attempts to HTTPS before sending the request. Scope: MDN documents user-agent enforcement after the header has been learned; first-visit protection requires preload or a prior secure visit. Confidence: high · Verified: MDN: Strict-Transport-Security header
Two granica conditions worth będąc precise o. pierwszy, HSTS jest stored, per-client polityka — it lives in że one przeglądarka’s own state dla że host, learned z a header delivered ponad a secure connection; the same header sent on an HTTP odpowiedź jest ignored outright (an attacker who może inject lub strip headers on plain HTTP mógł otherwise neutralize it), i a client że ma nigdy received it — a fresh install, a różny przeglądarka, a crawler — ma no polityka to enforce. Second, the rewrite jest scheme-i-port aware: an implicit port 80 żądanie becomes an implicit port 443 żądanie, ale if the original URI named an explicit non-domyślny port, the przeglądarka zachowuje że same port liczba i simply contacts it ponad HTTPS instead.
The header syntax
HSTS jest one nagłówek odpowiedzi z up to three directives. Per MDN, the forms są:
Strict-Transport-Security: max-age=31536000
Strict-Transport-Security: max-age=31536000; includeSubDomains
Strict-Transport-Security: max-age=63072000; includeSubDomains; preloadmax-age=<seconds>— required. “The time, in seconds, that the browser should remember that a host is only to be accessed using HTTPS” (MDN).31536000jest one year;63072000jest two. The clock resets on każdy odpowiedź że carries the header, so an active witryna continually renews jego polityka. ten jest relative, per-client state: simply removing the header doesn’t immediately jasny it — a przeglądarka że już learned the polityka zachowuje enforcing it until jego storedmax-ageruns out. To turn HSTS off dla clients że już learned it, you mieć to actively servemax-age=0ponad a secure odpowiedź; the przeglądarka then forgets the polityka on jego następny secure visit. (max-age=0clears a learned polityka tylko — it robi nie remove a domain z the oddzielny preload lista.)includeSubDomains— optional. “If this directive is specified, the HSTS policy applies to all subdomains of the host’s domain as well” (MDN). Powerful i dangerous in equal mierzyć — see the lockout scenarios below.preload— optional. A flag że signals twój intent to być on the przeglądarka preload lista. It robi nothing on jego own; it’s a prerequisite dla submitting to hstspreload.org. Evidence for this claim HSTS preload requires at least a one-year max-age, includeSubDomains, and preload; removal can take months to reach users. Scope: The Chromium preload service documents submission and removal behavior; requirements can change and should be rechecked before submission. Confidence: high · Verified: Chromium: HSTS Preload List Submission
The behavior, again z MDN:
“Before loading an http URL, the browser checks the domain name against its HSTS
hosts list. If the domain name is a case insensitive match for an HSTS host or is a
subdomain of one that specified includeSubDomains, then the browser replaces the
URL scheme with https.”
The internal upgrade crawlers nigdy see (ten jest the SEO crux)
Here’s the single najbardziej misunderstood thing o HSTS, i the powód it może’t zastępować twój redirects.
gdy a przeglądarka upgrades an http:// żądanie poniżej HSTS, it rewrites the URI to
HTTPS internally, przed dowolny network żądanie jest made — RFC 6797 wymaga the
scheme substitution itself ale robi nie mandate a particular kod stanu dla it
(RFC 6797 §8,3), so a
given przeglądarka lub crawling narzędzie może represent że internal krok however it likes —
wiele display it as an internal 307, ale że’s client/narzędzie-specific, nie a protokół
guarantee. co matters dla SEO jest simpler i holds regardless of the label: no
serwer jest contacted dla the HTTP version, so no crawler ever sees it. Googlebot i
Bingbot don’t carry a learned HSTS polityka around the way a returning człowiek’s Chrome
robi — they hit twój serwer fresh, i co they need to see there jest a rzeczywisty,
serwer-side 301. Evidence for this claim RFC 6797 requires the user agent to rewrite a known-HSTS-host HTTP URI to HTTPS internally, but does not mandate any specific redirect status code for that internal rewrite; how a given browser or crawling tool represents that step (e.g., as an internal 307) is a client/tool implementation detail, not a protocol requirement. Scope: RFC 6797 Section 8.3 ("URI Loading and Port Mapping") specifies the UA MUST replace the URI scheme with https; it does not prescribe an HTTP status code for that internal substitution, since no HTTP exchange occurs for it. Section 7.2's suggestion of status code 301 addresses ordinary server-side redirect behavior, not this internal client-side rewrite. Confidence: high · Verified: RFC 6797 §8.3 — URI Loading and Port Mapping
So the reguła jest blunt: HSTS robi nie zastępować twój serwer-side 301s. The 301 jest co wyszukiwarki używać to zrozum protokół move i to consolidate signals (301 i other permanent redirects don’t cause a loss in PageRank, per Google). The przeglądarka-tylko internal upgrade jest a użytkownik-experience i security warstwa on top. You need oba, doing różny jobs:
- 301 (serwer-side): dla crawlers, indeksowanie, i link equity.
- Internal 307-style upgrade (przeglądarka-side, z HSTS): dla returning humans i SSL-stripping protection — the dokładny status representation varies by client/narzędzie.
dowolny poradnik że tells you HSTS “handles the redirect so you can drop your 301” jest błędny in a way że będzie quietly cost you.
HSTS preload: the near-permanent version
max-age protects returning visitors, ale it ma a bootstrap problem: a
pierwszy-time visitor who ma nigdy received twój header jest nadal exposed on że
initial żądanie. Preload solves it by hardcoding twój domain do the przeglądarka’s
źródło itself, so the przeglądarka knows you’re HTTPS-tylko przed it ma ever connected.
You opt in at hstspreload.org. The requirements są dokładny:
- “Serve a valid certificate.”
- “Redirect from HTTP to HTTPS on the same host, if you are listening on port 80.”
- “Serve all subdomains over HTTPS” — w tym w szczególności the
wwwsubdomain if a DNS record exists. - On the base domain’s HTTPS odpowiedź, an HSTS header gdzie “the
max-agemust be at least31536000seconds (1 year),” “theincludeSubDomainsdirective must be specified,” i “thepreloaddirective must be specified.” (hstspreload.org)
że’s why the two-year przykład above (max-age=63072000; includeSubDomains; preload)
jest the shape people submit — note te są the dokładny submission requirements as
opublikowany by hstspreload.org; treat them as the current bar, nie a permanent
constant, i re-sprawdź live strona przed you submit.
It pomaga to zachować four distinct states straight, since people conflate them constantly:
| State | co’s actually prawdziwy |
|---|---|
| Token present | twój header obejmuje preload. ten jest a flag tylko — it robi nothing by itself i doesn’t put you on dowolny lista. |
| Eligible | twój witryna meets wszystkie four hstspreload.org requirements above (cert, redirect, subdomains, header shape). nadal nie on the lista. |
| Submitted / pending | You’ve submitted at hstspreload.org i it’s queued dla inclusion in an upcoming przeglądarka release. nie yet enforced dla rzeczywisty użytkownicy. |
| Actually listed | The domain jest baked do a given przeglądarka’s shipped build. Enforcement tylko exists dla użytkownicy on że build — rollout isn’t instant lub universal w całym przeglądarki. |
Removal runs the same four states in reverse, i just as slowly: removing the
preload directive z twój header makes you eligible dla the removal form, then
submission jest pending, i the domain stays enforced dla dowolny użytkownik on a przeglądarka build
że nadal ships it — until że build cycles out.
Now the part że turns preload do a one-way door. z the submission witryna itself: “Be aware that inclusion in the preload list cannot easily be undone. Domains can be removed, but it takes months for a change to reach users with a Chrome update and we cannot make guarantees about other browsers.” (hstspreload.org). i jego own advice: “Don’t request inclusion unless you’re sure that you can support HTTPS for your entire site and all its subdomains in the long term.”
Practical tłumaczenie: preload jest a genuinely great security posture, ale if you ever need to serve anything — a legacy subdomain, an acquired marka, an internal narzędzie — ponad plain HTTP again, you’re stuck waiting on przeglądarka release cycles to reach każdy użytkownik. Kinsta’s poradnik puts the operational reality plainly: it może być a difficult i time-consuming proces to get twój domain removed. Treat preload as permanent.
Why HSTS jest designed to hurt gdy things break
HSTS’s strictness jest nie a bug — it’s the entire security guarantee. web.dev spells out the tradeoff: “Clients that have listed your site as a known HSTS Host are likely to hard-fail if your site ever has an error in its TLS configuration, (such as an expired certificate). HSTS is explicitly designed this way to ensure that network attackers can’t trick clients into accessing the site without HTTPS.” (web.dev).
The conclusion Google draws jest the zdanie I’d tattoo on anyone o to flip ten on: “Don’t enable HSTS until you’re certain your site operation is robust enough to avoid ever deploying HTTPS with certificate validation errors.” (web.dev).
“Hard-fail” means exactly że: no “proceed anyway” link, no click-przez. On a normal HTTPS strona, an expired cert throws a scary interstitial że a determined użytkownik może bypass. On an HSTS host, the przeglądarka refuses outright. So the awaria mode of a missed certificate renewal changes kategoria — z “traffic dips because people are scared off” to “the site is unreachable for every returning visitor.”
rzeczywisty-world lockout scenarios
The ways HSTS bites w praktyce almost zawsze trace back to includeSubDomains lub
preload getting ahead of twój rzeczywisty HTTPS coverage:
- The forgotten subdomain. You ustawić
includeSubDomainsonexample.com, alelegacy.example.com(an old app, a status strona, a vendor narzędzie) tylko speaks HTTP lub ma a cert że doesn’t cover it. każdy przeglądarka że saw the header now refuses to load że subdomain. Nothing changed on że serwer — the polityka reached down i broke it. - The wildcard-cert gap. A
*.example.comwildcard coversfoo.example.comale niefoo.bar.example.com(a wildcard jest one DNS label deep). If a deeper subdomain relies on HTTP lub a mismatched cert,includeSubDomainslocks it out. - The expired cert on an HSTS host. Renewal automation fails, the cert lapses, i zamiast a bypassable ostrzeżenie you get a witryna że’s down dla everyone whose przeglądarka remembers twój polityka — until you get a prawidłowy cert back i they reconnect i receive a fresh secure odpowiedź. There jest no faster override.
- Preload regret. You preloaded, then a firma need forces an HTTP-tylko
service poniżej the domain. Rolling że back jest two oddzielny, non-instant jobs, nie
one: serving
max-age=0ponad HTTPS tylko clears the learned polityka dla clients że reconnect przed ich old max-age by’ve expired anyway, podczas gdy getting the domain out of the preload lista jest a distinct submission że nadal takes przeglądarka release cycles — months — to reach użytkownicy, independent of anything you change on twój serwer. - Local dev / staging collisions. Preloading
example.comzincludeSubDomainsmoże makedev.example.comlub alocalhost-style internal host poniżej the same apex refuse HTTP, breaking local przepływy pracy in surprising ways.
None of te są powody to avoid HSTS. They’re powody to stage it: short
max-age pierwszy, dodawać includeSubDomains tylko po auditing każdy subdomain, i
reserve preload dla gdy you’re certain.
HSTS jest nie a ranking play (i doesn’t touch canonicalization)
To być jasny on the SEO framing: HSTS jest nie a ranking signal. HTTPS itself jest
a deliberately tiny one — Google called it a “very lightweight
signal” affecting fewer than 1% of zapytania — i HSTS jest a warstwa on top of HTTPS, nie
a oddzielny ranking input. It również doesn’t directly control canonicalization lub
indeksowanie. Google’s own documentation jest więcej specific than a flat “doesn’t matter,”
though: Google prefers HTTPS as canonical ponad an equivalent HTTP strona except
gdy there’s an nieprawidłowy certificate, insecure strona dependencies, an HTTPS strona że
redirects to HTTP, lub an HTTP rel="canonical" znacznik
(Google: consolidating duplicate URLs).
HSTS cannot fix lub override dowolny of że. It’s a przeglądarka-side polityka z no
influence on Google’s canonicalization logic — a bad certificate lub a broken redirect
chain może nadal push Google toward an HTTP canonical regardless of co twój HSTS
header says. Canonicalization jest driven by twój 301s, twój certificate, twój
rel="canonical", i twój linki wewnętrzne — HSTS earns jego place dla security,
użytkownik trust, i closing the SSL-stripping gap — robić it dla tamte powody, zachować twój
301s i certificate genuinely solid, i you’ll nigdy see HSTS itself on a rankings
raport either way.
If you’re running the broader HTTP→HTTPS move, HSTS jest the ostatni thing you switch on, nie the pierwszy — it belongs po the migration ma settled, as part of the wider migracja witryny discipline.
AI summary
A condensed take on the Advanced version:
- HSTS = the
Strict-Transport-Securitynagłówek odpowiedzi. It tells przeglądarki to zawsze używać HTTPS dla twój domain, closing the “first request problem” a 301 alone leaves otwarty — the initial HTTP żądanie z a new visitor jest insecure until the redirect fires, który jest the SSL-stripping window. - Three directives:
max-age(required, seconds; resets on każdy odpowiedź; removing the header doesn’t jasny a learned polityka — you musi servemax-age=0ponad HTTPS instead),includeSubDomains(applies to wszystkie subdomains), ipreload(a flag to opt do the przeglądarka preload lista — token present, eligible, submitted, i actually listed są four oddzielny states). - The internal-upgrade crux: gdy a przeglądarka enforces HSTS it rewrites the URI to HTTPS internally przed dowolny żądanie reaches a serwer — RFC 6797 doesn’t mandate a specific kod stanu dla że rewrite, though narzędzia często pokazywać it as a 307 — so no serwer sees it i crawlers nigdy see it. twój serwer-side 301s są nadal mandatory dla wyszukiwarki i link equity. HSTS jest on top of twój 301s, nigdy zamiast them.
- Preload hardcodes twój domain do the przeglądarka via
hstspreload.org (wymaga
max-age≥ 31536000,includeSubDomains, ipreload). It’s close to irreversible — removal jest a oddzielny submission że takes months to reach użytkownicy, przeglądarka by przeglądarka. - Designed to trudny-fail: an HSTS host z a broken/expired cert refuses to load, z no click-przez. Google: “Don’t enable HSTS until you’re certain your site operation is robust enough to avoid ever deploying HTTPS with certificate validation errors.”
- Lockout scenarios cluster around
includeSubDomainsi preload outrunning twój HTTPS coverage: forgotten HTTP subdomains, wildcard-cert depth gaps, lapsed certs, preload regret, i staging collisions. - nie a ranking signal — i może’t override canonicalization. Google prefers HTTPS as canonical except gdy a cert jest nieprawidłowy, dependencies są insecure, an HTTPS strona redirects to HTTP, lub the znacznik kanoniczny points to HTTP — i HSTS ma no power to fix lub override dowolny of że. zachować twój 301s, certificate, i canonical znaczniki doing the SEO działać.
Official documentation
Primary-źródło documentation z przeglądarka i standardy zespoły.
Google / web.dev
- Enable HTTPS on twój serwery (web.dev) — the HSTS sekcja: the header, SSL-stripping, the trudny-fail ostrzeżenie, i “don’t enable HSTS until you’re certain.”
- witryna moves z URL changes — why the serwer-side 301 jest nadal mandatory (redirects don’t lose PageRank).
- Understanding strona experience — gdzie HTTPS (i by extension HSTS) sits in Google’s framing.
standardy & przeglądarka references
- MDN —
Strict-Transport-Security— pełny header syntax, the three directives, i how the przeglądarka upgrades the scheme. - RFC 6797 — HTTP Strict Transport Security (HSTS) — the original specification.
- HSTS Preload lista submission (hstspreload.org) — the dokładny preload requirements i the removal caveats, maintained by the Chromium project.
cytaty z the źródło
On-the-record statements z Google/web.dev i the Chromium preload service. każdy link jumps to (lub points at) the quoted passage on the źródło strona.
web.dev (Google) — co HSTS robi i the ostrzeżenia
- “Use HTTP Strict Transport Security (HSTS) to avoid the cost of the 301 redirect.” Jump to cytat
- “First, use Strict Transport Security to tell clients they should always connect to
your server using HTTPS, even when following an
http://reference. This defeats attacks like SSL Stripping, and avoids the round-trip cost of the 301 redirect.” Jump to cytat - “Clients that have listed your site as a known HSTS Host are likely to hard-fail if your site ever has an error in its TLS configuration, (such as an expired certificate). HSTS is explicitly designed this way to ensure that network attackers can’t trick clients into accessing the site without HTTPS.” Jump to cytat
- “Don’t enable HSTS until you’re certain your site operation is robust enough to avoid ever deploying HTTPS with certificate validation errors.” Jump to cytat
Chromium preload service — hstspreload.org
- “Be aware that inclusion in the preload list cannot easily be undone. Domains can be removed, but it takes months for a change to reach users with a Chrome update and we cannot make guarantees about other browsers.” źródło
- “Don’t request inclusion unless you’re sure that you can support HTTPS for your entire site and all its subdomains in the long term.” źródło
MDN — the header behavior
- “Before loading an
httpURL, the browser checks the domain name against its HSTS hosts list. If the domain name is a case insensitive match for an HSTS host or is a subdomain of one that specifiedincludeSubDomains, then the browser replaces the URL scheme withhttps.” źródło
powinien I enable HSTS — i how far?
Walk it top to bottom. każdy “no” jest a stop sign, nie a maybe. One distinction przed
you start: the dokładny max-age figures below (a kilka minutes dla a canary, a year dla
a resting state) są Patrick’s operational staging recommendations, nie protokół
requirements — the tylko trudny numeric requirement jest hstspreload.org’s preload
minimum (max-age ≥ 31536000), który jest called out explicitly at że krok. Adjust
the staging durations to twój own risk tolerance i deployment cadence.
1. jest twój whole witryna już on HTTPS z a prawidłowy certificate, i ma the migration settled?
- No → Don’t touch HSTS yet. Finish the HTTPS migration pierwszy: 301 każdy URL, fix mixed treść, verify in Search Console. HSTS jest the ostatni switch, nie the pierwszy.
- Yes → continue.
2. jest twój certificate renewal automated i monitored (so a lapse może’t sneak up on you)?
- No → Fix że pierwszy. On an HSTS host a lapsed cert jest a trudny outage, nie a ostrzeżenie. Get auto-renewal + expiry alerting in place, then continue.
- Yes → continue. Enable a short
max-age(e.g. a kilka minutes to a day) z noincludeSubDomainsyet, i confirm nothing breaks.
3. mieć you audited każdy subdomain — w tym www, legacy apps, status strony,
i vendor hosts — i confirmed każdy serves prawidłowy HTTPS?
- No → zachować
includeSubDomainsoff. Adding it now by reach down i break dowolny HTTP-tylko lub mismatched-cert subdomain. - Yes → Raise
max-agetoward a year i dodawaćincludeSubDomains. ten jest a bezpieczny, strong resting state dla najbardziej witryny.
4. robić you want to close the pierwszy-ever-visit gap too, i są you certain you’ll nigdy need to serve anything poniżej ten domain ponad plain HTTP again?
- No / nie sure → Stop here.
max-age=31536000; includeSubDomains(no preload) jest an excellent posture. Preload’s marginal gain isn’t worth jego irreversibility if you’re unsure. - Yes, certain → dodaj
preloadflag i submit at hstspreload.org. Treat it as permanent — removal takes months to reach użytkownicy.
oddzielny, zawsze-prawdziwy branch: robi enabling HSTS mean I może drop my 301s?
- nigdy. Crawlers don’t see HSTS’s przeglądarka-tylko internal upgrade. zachować twój serwer-side 301s regardless of how far down ten tree you go.
HSTS rollout checklist
działać top to bottom — każdy stage gates the następny. The staged durations here są
operational recommendations, nie protokół requirements — the tylko trudny liczba jest
preload’s max-age ≥ 31536000 minimum in Stage 3.
przed you enable anything
- Entire witryna (apex +
www+ wszystkie subdomains) serves HTTPS z a prawidłowy cert. - HTTP→HTTPS 301 redirects są in place serwer-side, one-to-one.
- Certificate auto-renewal jest configured i expiry monitorowanie/alerting exists.
- The HTTP→HTTPS migration ma settled (Search Console clean, no ranking freefall).
Stage 1 — prove it’s bezpieczny
- dodawać
Strict-Transport-Securityz a shortmax-age(minutes to a day). - No
includeSubDomainsyet. Nopreloadyet. - Confirm the witryna loads normally w całym przeglądarki i że nothing broke.
Stage 2 — commit
- Raise
max-ageto co najmniej31536000(one year). - Audit każdy subdomain (incl.
www, legacy, status, vendor) dla prawidłowy HTTPS. - tylko po że audit passes, dodawać
includeSubDomains. - Re-test każdy subdomain loads ponad HTTPS.
Stage 3 — preload (optional, near-permanent)
- You’re certain you’ll nigdy need HTTP poniżej ten domain again.
- Header jest
max-age=31536000(lub więcej); includeSubDomains; preload. - HTTP on port 80 redirects to HTTPS on the same host.
- Submit i confirm status at hstspreload.org.
zawsze prawdziwy — don’t skip
- serwer-side 301s stay in place (crawlers nigdy see the przeglądarka-tylko internal upgrade).
- You mieć a udokumentowany rollback plan:
max-age=0served ponad HTTPS clears a learned (non-preloaded) polityka dla clients że reconnect przed it by’ve expired anyway. Preloaded domains need the oddzielny, slower removal-form proces instead.
The mental modele
1. HSTS jest a warstwa, nie a replacement. serwer-side 301 = dla crawlers i link equity. przeglądarka-side internal upgrade (z HSTS, często shown as a 307 though the RFC doesn’t wymagać że dokładny code) = dla returning humans i SSL-stripping protection. różny audiences, różny jobs. You zawsze need oba; HSTS nigdy subtracts a 301.
2. HSTS closes a gap the 301 może’t. A 301 protects the second żądanie onward. The pierwszy żądanie — przed the redirect fires — jest nadal HTTP. HSTS (dla returning visitors) i preload (dla pierwszy-ever visitors) są the tylko things że close że specific window.
3. Ratchet up, nigdy jump.
max-age short → long. Bare header → includeSubDomains (po a subdomain audit) →
preload (tylko if certain). każdy rung jest reversible except the ostatni. Don’t skip
rungs to save time.
4. Strictness jest the funkcja, i it cuts oba ways. The same trudny-fail że stops an attacker również stops you gdy a cert breaks. So the prerequisite isn’t “do you want security?” — everyone robi — it’s “is your certificate operation robust enough to never fail?”
5. Preload jest a one-way door.
Non-preloaded HSTS może być relaxed dla a client the następny time it makes a secure
żądanie i receives max-age=0 — no faster than że, i tylko dla clients who
reconnect. Preload takes it a krok further: removal jest a oddzielny submission że
takes months to reach użytkownicy, przeglądarka release by przeglądarka release. Put it in the
“decisions we can’t easily take back” bucket i treat it accordingly.
6. HSTS jest orthogonal to rankings — ale może’t rescue a bad canonical signal either. It’s nie a ranking signal i doesn’t directly control canonicalization lub indeksowanie. Judge it on security i trust, nie on SEO upside — there isn’t dowolny. ale it’s nie a safety net either: Google’s HTTPS-canonical preference nadal backs off dla a bad cert, insecure dependencies, an HTTPS→HTTP redirect, lub an HTTP znacznik kanoniczny, i HSTS ma no power to override że.
HSTS — cheat sheet
The header directives
| Directive | Required? | co it robi |
|---|---|---|
max-age=<seconds> | Yes | How long the przeglądarka enforces HTTPS-tylko. Resets on każdy odpowiedź ponad HTTPS; removing the header doesn’t jasny it — you musi serve max-age=0 ponad HTTPS to disable dla reconnecting clients. |
includeSubDomains | No | Applies the polityka to każdy subdomain too. Audit wszystkie subdomains pierwszy. |
preload | No | Flag opting do the przeglądarka preload lista (needs the other two + hstspreload.org). Token present, eligible, submitted, i actually listed są four oddzielny states. Near-irreversible once listed. |
Common header wartości (staging figures below są operational suggestions, nie protokół requirements — the trudny minimum jest the preload row)
| wartość | Meaning |
|---|---|
max-age=300 | 5 minutes — a bezpieczny pierwszy test. |
max-age=31536000 | 1 year — standard resting state. |
max-age=31536000; includeSubDomains | 1 year, wszystkie subdomains — strong, non-preload. |
max-age=63072000; includeSubDomains; preload | 2 years + preload — the shape you submit (hstspreload.org’s required minimum jest max-age ≥ 31536000). |
max-age=0 (served ponad HTTPS) | Clears a learned polityka dla clients że reconnect. robi nie remove a preload listing. |
Redirects: który one, who sees it
| Redirect | Origin | Who sees it | Job |
|---|---|---|---|
| 301 | twój serwer | Crawlers i humans | SEO: zrozum move, carry link equity |
| Internal upgrade (często shown as a 307; RFC 6797 doesn’t mandate the dokładny code) | The przeglądarka (HSTS) | Returning humans tylko — crawlers nigdy see it | Security/UX: skip the insecure pierwszy hop |
Fast fakty
- Preload wymaga
max-age≥ 31536000 +includeSubDomains+preload— verified wobec hstspreload.org’s current opublikowany requirements. - Preload removal jest a oddzielny submission że takes months to reach użytkownicy, przeglądarka by przeglądarka — treat as permanent.
- On an HSTS host, a broken cert = trudny-fail, no click-przez.
- HSTS jest nie a ranking signal i robi nie zastępować twój 301s.
ustawić the HSTS header
dodaj header on twój HTTPS serwer blok tylko, i zacznij od a short max-age
until you’ve confirmed nothing breaks. dodawać ; preload tylko gdy you intend to
submit to hstspreload.org — it’s close to irreversible.
Apache (.htaccess)
<IfModule mod_headers.c>
# Start short (300s) to prove it's safe; raise to 31536000 once confident.
Header always set Strict-Transport-Security "max-age=300"
# Full posture once every subdomain is verified HTTPS:
# Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
# Only add ; preload when submitting to hstspreload.org:
# Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
</IfModule>Nginx
# On the HTTPS (listen 443) server block:
add_header Strict-Transport-Security "max-age=300" always;
# Full posture once subdomains are verified:
# add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
# Preload shape (near-irreversible):
# add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;sprawdzenie whether HSTS jest ustawić (i read it back)
macOS / Linux
# Print only the Strict-Transport-Security response header
curl -sI https://example.com/ | grep -i strict-transport-security
# → strict-transport-security: max-age=31536000; includeSubDomainsWindows (PowerShell)
# Same check in PowerShell
(Invoke-WebRequest -Uri "https://example.com/" -Method Head).Headers["Strict-Transport-Security"]Inspect i jasny an HSTS entry in Chrome (DevTools / net-internals)
If you’re testing i a przeglądarka ma “learned” an HSTS polityka you need to jasny:
1. Open a new tab and visit: chrome://net-internals/#hsts
2. Under "Query HSTS/PKP domain", enter your host to see the stored policy.
3. Under "Delete domain security policies", enter the host and Delete.
(This clears the *learned* policy — it does NOT remove a *preloaded* domain,
which lives in the browser binary and can't be cleared this way.)używać ten to confirm twój header jest actually będąc stored, i to reset a test host —
nie as a fix dla production, gdzie the answer jest to actively serve max-age=0 ponad
HTTPS (simply removing the header doesn’t jasny a polityka a client już learned;
it tylko takes effect once że client reconnects i receives the max-age=0
odpowiedź).
HSTS mistakes że bite
1. Dropping twój 301s ponieważ “HSTS handles it.” The classic. HSTS’s redirect jest a przeglądarka-tylko internal upgrade crawlers nigdy see. Remove twój serwer-side 301s i wyszukiwarki lose the signal że consolidates twój move. zachować oba, zawsze.
2. Enabling includeSubDomains przed auditing subdomains.
The single najbardziej common way to take a subdomain offline. If dowolny subdomain — a legacy
app, a status strona, a vendor host, www itself — isn’t on prawidłowy HTTPS, the polityka
reaches down i breaks it dla każdy przeglądarka że saw the header.
3. Jumping straight to a one-year max-age (lub preload) on day one.
No safety net. Start short (max-age=300), confirm nothing breaks, then ratchet up.
A long max-age ustawić on a misconfigured witryna jest a self-inflicted outage że lingers
in przeglądarki dla a year.
4. Preloading przed HTTPS jest genuinely bulletproof. Preload jest near-irreversible — removal takes months. Google’s own wiersz: don’t enable HSTS until you’re certain twój witryna operation jest robust enough. Preload multiplies że stakes.
5. Treating a lapsed certificate as a minor problem. On a non-HSTS witryna an expired cert jest a bypassable ostrzeżenie. On an HSTS host it’s a trudny outage z no click-przez. If you enable HSTS, cert renewal automation i expiry alerting stop będąc nice-to-haves.
6. Setting the header on the HTTP odpowiedź. przeglądarki ignore HSTS delivered ponad HTTP (by design — an attacker mógł inject lub strip it). It musi być sent on the HTTPS odpowiedź to count.
7. Forgetting the wildcard-cert depth limit.
A *.example.com wildcard doesn’t cover foo.bar.example.com. Turn on
includeSubDomains i dowolny deeper subdomain relying on że cert gets locked out.
Incident playbook: an HSTS host jest locked out
- Confirm the awaria z a clean network i więcej niż one przeglądarka. Record the affected hostnames i the dokładny certificate błąd. A remembered HSTS polityka może make the symptom differ między returning i pierwszy-time visitors.
- Restore prawidłowy HTTPS pierwszy. If the certificate jest expired, mismatched, lub missing an intermediate, renew lub zastępować it i deploy the complete chain. An HSTS przeglądarka będzie nie oferta a bezpieczny HTTP bypass.
- Map the polityka scope. Inspect the live
Strict-Transport-Securityheader i determine whetherincludeSubDomainslub preload extends the outage beyond the hostname że sent it. - stan magazynowy każdy affected subdomain. dla a forgotten HTTP-tylko host, put a prawidłowy certificate i HTTPS endpoint in front of it przed deciding whether to zachować, migrate, lub redirect the service.
- poprawny the polityka tylko po access jest restored. If the scope jest unsafe, reduce lub usuń header on HTTPS odpowiedzi. że robi nie instantly jasny a polityka już cached by przeglądarki, i preload removal jest a oddzielny, slow proces.
- Verify odzyskiwanie. Test the apex,
www, i każdy affected subdomain dla a prawidłowy chain, poprawny hostname, one-hop HTTP→HTTPS redirect, i the intended HSTS header. zachować certificate-expiry monitorowanie on the same stan magazynowy.
robić nie tear down the HTTP redirect lub tell użytkownicy to bypass the ostrzeżenie. The durable fix jest a prawidłowy HTTPS endpoint everywhere the active HSTS polityka reaches.
Audit a live HSTS polityka
Act as a security-minded technical SEO. Review this Strict-Transport-Security
header, the HTTP redirect response, and the supplied subdomain inventory.
For the header, parse max-age, includeSubDomains, and preload. Explain the effective
scope, identify subdomains whose HTTPS or certificate coverage is unproven, and
separate browser-side HSTS behavior from the server-side 301 search engines need. Use
GET requests (HEAD can behave differently on some servers/clients), and record which
client or tool produced each observation and its version, since internal-redirect
representation is client/tool-specific rather than a fixed protocol value.
Recommend the next rollout stage: keep a short max-age canary, lengthen max-age,
add includeSubDomains, or consider preload. Do not recommend preload unless the
evidence shows a valid certificate, same-host HTTP→HTTPS redirects, HTTPS on every
subdomain, max-age of at least 31536000, includeSubDomains, and the preload token.
Return: observed configuration, risks, blocking evidence, next action, rollback
constraint, and exact validation checks.Triage an HSTS lockout
Given the affected hostnames, browser error, certificate details, DNS/CDN layout,
and live response headers, identify whether this is an expired certificate, hostname
mismatch, incomplete chain, includeSubDomains spillover, or preload issue. Prioritize
restoring valid HTTPS. Explain why removing a header does not immediately erase a
cached browser policy, then provide recovery and verification steps. HSTS inspection toolkit
- HTTP Header Checker — inspect the live
Strict-Transport-Securityheader i confirm it appears on HTTPS odpowiedzi. curl -I— porównaj HTTP redirect z the HTTPS header bez relying on a przeglądarka’s remembered HSTS state.- przeglądarka DevTools — confirm the final odpowiedź headers i certificate błąd seen by a rzeczywisty client.
- HSTS preload status — sprawdzenie submission requirements i whether the domain jest już represented in the preload proces.
używać co najmniej two views: command-wiersz output pokazuje the serwer odpowiedź, podczas gdy a przeglądarka również exposes client-side enforcement i certificate trudny awarie. Prefer GET ponad HEAD gdy comparing narzędzia — niektóre serwery i clients represent the two differently — i note the dokładny client/narzędzie/version behind każdy reading.
Staged HSTS rollout tests
Test 0: the state matrix (run ten przed staging changes)
HSTS status isn’t one fakt — it’s several independent states że może disagree. Track them osobno, per hostname:
| Dimension | co to sprawdzenie | Notes |
|---|---|---|
| Live HTTPS header, by odpowiedź class | The Strict-Transport-Security wartość on rzeczywisty HTTPS odpowiedzi (home strona, deep strony, API/asset odpowiedzi może differ) | używać GET, nie HEAD — niektóre serwery/CDNs vary header emission by metoda |
| Port-80 redirect | A genuine serwer-side redirect exists on port 80, nie just reliance on a learned client polityka | ten jest co pierwszy-time i non-HSTS clients depend on |
| Certificate coverage | prawidłowy chain dla the apex, www, i każdy subdomain in scope | Wildcard certs don’t cover a second DNS label deep |
| Parent vs. entry-point subdomains | Whether a directly-visited subdomain ma actually received jego own HSTS odpowiedź, since it może nie inherit a parent’s learned polityka the way includeSubDomains implies on paper | Test każdy entry point directly, nie just the apex |
| Learned state, fresh vs. returning client | Behavior on a client że ma nigdy seen twój header vs. one że ma | jasny przeglądarka HSTS state (lub używać a clean profile) to simulate “fresh” |
| rzeczywisty preload status | Whether the domain jest listed in a given przeglądarka’s shipped build, nie just submitted | sprawdzenie via the przeglądarka’s own status strona/flag, nie just the submission form |
Record the client, narzędzie, i version dla każdy observation — internal-redirect representation i HSTS enforcement details vary w całym przeglądarki, crawlers, i command-wiersz narzędzia, i a stale reading z one client może look like a contradiction że isn’t rzeczywisty.
Test 1: short max-age canary
- Purpose: Prove the header jest emitted tylko z healthy HTTPS odpowiedzi przed committing clients to a long polityka.
- metoda: Inspect representative templates i hosts z the HTTP Header Checker
i
curl -I; porównaj deployed wartość z the approved canary konfiguracja. - Expected wynik: HTTPS odpowiedzi carry the intended short
max-age; HTTP nadal zwroty a serwer-side stałe przekierowanie to HTTPS. - awaria trigger: Missing lub duplicated headers, an unexpected long duration, certificate błędy, lub dowolny redirect loop.
- następny action: Fix the header lub HTTPS endpoint i zachowaj rollout at the canary stage.
Test 2: includeSubDomains readiness
- Purpose: zapobiegać a parent polityka z locking out a forgotten hostname.
- metoda: Test każdy DNS hostname in the maintained subdomain stan magazynowy dla a prawidłowy HTTPS odpowiedź, poprawny certificate nazwa, i complete chain.
- Expected wynik: każdy in-scope subdomain działa ponad HTTPS, w tym legacy, vendor, development, i deeper-level hosts.
- awaria trigger: dowolny HTTP-tylko service, expired lub mismatched certificate, lub hostname missing z the stan magazynowy.
- następny action: Remediate lub relocate the host przed adding
includeSubDomains.
Test 3: preload readiness
- Purpose: Verify the near-permanent polityka satisfies the udokumentowany submission requirements.
- metoda: Confirm a prawidłowy certificate, same-host HTTP→HTTPS redirects, HTTPS on
wszystkie subdomains, i an apex header z
max-ageof co najmniej31536000,includeSubDomains, ipreload. - Expected wynik: każdy requirement passes i the organization accepts the slow removal path.
- awaria trigger: dowolny failed technical requirement lub an unresolved need dla an HTTP-tylko subdomain.
- następny action: robić nie submit; pozostawać on the reversible staged polityka.
zasoby worth twój time
My speaking
- Better bezpieczny Than Sorry z HTTPS — SMX East 2016 (SlideShare) — my deep-dive on TLS, common HTTPS implementacja awarie, i the migration gotchas że HSTS oba closes i może amplify. (Standing disclaimer applies: it’s my understanding of te systemy, i the adoption stats in it są z 2016.)
My powiązany writing
- The Beginner’s poradnik to techniczne SEO — gdzie HTTPS i HSTS fit in the bigger picture.
z around the industry
- Enable HTTPS on twój serwery (web.dev) — Google’s own HSTS guidance: the header, SSL-stripping, i the trudny-fail ostrzeżenie.
- MDN —
Strict-Transport-Security— the authoritative header reference: syntax, directives, i scheme-upgrade behavior. - HSTS Preload lista submission (hstspreload.org) — the Chromium project’s preload requirements i the near-irreversibility caveats.
- RFC 6797 — HTTP Strict Transport Security — the original specification, dla gdy you need the dokładny wording of a directive.
- HSTS — co It jest i How to używać It (Kinsta) — a practical implementacja poradnik covering the przeglądarka-level internal redirect, the preload lista, i the lock-in risks.
- SSL Labs serwer Test (Qualys) — grade twój TLS konfiguracja i confirm HSTS jest będąc served correctly.
Stats i trudny fakty worth citing
- Preload wymaga
max-age≥ 31536000 (1 year),includeSubDomains, ipreload. The dokładny, non-negotiable submission bar dla the przeglądarka-baked lista. źródło - Preload removal takes months to reach użytkownicy. z the submission service: “inclusion in the preload list cannot easily be undone… it takes months for a change to reach users with a Chrome update.” ten jest the liczba że makes preload a one-way door. źródło
- HSTS hosts trudny-fail on dowolny TLS błąd. web.dev: clients że know twój witryna as an HSTS host “are likely to hard-fail if your site ever has an error in its TLS configuration.” No click-przez — a lapsed cert becomes an outage. źródło
- HTTPS itself jest “a very lightweight signal—affecting fewer than 1% of global queries.” Google’s own framing — i HSTS jest a warstwa on top of HTTPS, nie a oddzielny ranking input, so jego SEO weight jest effectively zero. Right-size expectations accordingly. źródło
Test yourself: HSTS
Five quick questions on HSTS. Pick an answer dla każdy, then sprawdzenie.
Dziennik zmian
Zaktualizowano 17 lip 2026.
Podsumowanie redakcyjne i zapisane szczegóły zmian.Szczegóły zmian
-
Szczegółowe uwagi dotyczące zmian są obecnie dostępne po angielsku.
Pełne porównanie jest niedostępne — dla tej wersji nie zarchiwizowano wcześniejszej migawki.