Mixed Nội dung
Điều gì mixed nội dung là, vì sao active mixed nội dung nhận blocked trong khi passive nhận warned về, và cách detect và cách sửa insecure sub-các tài nguyên tại quy mô — đó trình duyệt console, CSP reporting, upgrade-insecure-các yêu cầu, block-all-mixed-nội dung, và cách CMSes và quảng cáo tech reintroduce điều này.
Ngôn ngữ
Mixed nội dung là an HTTPS trang loading một sub-tài nguyên over HTTP. Các trình duyệt' hiện tại taxonomy là upgradable versus blockable; đó older active/passive split vẫn tracks đó cho hầu hết types, với exceptions (CORS-enabled images, srcset/picture, và IP-host các yêu cầu là blockable, không upgradable). Active mixed nội dung — scripts, stylesheets, iframes, XMLHttpRequest/fetch — là blocked outright vì một tampered script có thể rewrite đó toàn bộ trang, so đây là điều gì thực ra breaks một site sau an HTTP→HTTPS migration; cách sửa điều này đầu tiên. Passive mixed nội dung — images, audio, video — trong lịch sử loaded với một downgraded padlock và là hiện tại increasingly auto-upgraded hoặc blocked cũng. Anchor links và other top-cấp độ HTTP navigation không phải mixed nội dung, và neither là insecure downloads (một related, tách biệt boundary). Tìm điều này trên fetched nguồn, được kết xuất/runtime state, và real-người dùng sessions: crawl đó HTTPS site, watch đó Chrome DevTools console (chính xác wording là trình duyệt/version cụ thể), hoặc collect Nội dung-Security-Policy-Báo cáo-Chỉ violations; cách sửa điều này by đầu tiên confirming đó HTTPS tương đương thực ra hoạt động, thì pointing mỗi sub-tài nguyên tại https:// (relative/giao thức-relative paths chỉ sau verifying quyền sở hữu và base-URL behavior). Đó Nội dung-Security-Policy: upgrade-insecure-các yêu cầu header rewrites trong-phạm vi http:// sub-tài nguyên các yêu cầu — including cross-origin ones — để https:// trước họ là đã gửi và trước mixed-nội dung/CSP kiểm tra chạy; điều này có không HTTP fallback nếu đó upgrade fails, đây là một safety net thay vì một substitute cho cleaning đó nguồn, điều này không upgrade top-cấp độ navigation để bên thứ ba origins (so điều này không một replacement cho HSTS), và setting đó directive itself trong báo cáo-chỉ chế độ là một không-op — monitor với một tách biệt báo cáo-chỉ policy thay vì. CMS databases (lại lên và dry-chạy replacements — naive string-replace có thể corrupt serialized dữ liệu), plugin/themes, service workers/caches, và quảng cáo/analytics tags là đó thông thường re-offenders; audit tại quy mô với một crawler và CSP reporting thay vì trang by trang.
Tóm tắt — Mixed nội dung là Khi secure
https://trang loads điều gì đó — image, script, stylesheet — over insecurehttp://. đó mixes secure trang với insecure pieces, mà defeats point của HTTPS. các trình duyệt block dangerous kinds (scripts, styles, iframes) và warn về milder kinds (images, media). nó phần lớn phổ biến điều đó breaks trang web right sau khi bạn chuyển để HTTPS, và khắc phục là đơn giản: làm mỗi tài nguyên load overhttps://cũng.
Điều gì mixed nội dung là
Khi bạn move trang web để HTTPS, trang itself loads securely. nhưng trang là không bao giờ
chỉ HTML — nó pulls trong images, scripts, stylesheets, fonts, videos, và
đôi khi embedded frames từ khác places. nếu bất kỳ của những điều đó pieces là vẫn
requested over đơn giản http://, bạn có mixed nội dung: secure trang carrying
insecure cargo. Evidence for this claim Mixed content occurs when a secure page loads resources over insecure HTTP, and browsers upgrade or block mixed-content requests by resource type. Scope: MDN documents current browser categories and behavior; individual browser versions may differ at the margins. Confidence: high · Verified: MDN: Mixed content
As Google own explainer diễn đạt điều này, “A page has mixed content when its initial HTML is loaded over a secure HTTPS connection, but other resources (such as images, videos, stylesheets, and scripts) are loaded over an insecure HTTP connection.” (bản dịch) «MỘT trang có mixed nội dung khi của nó ban đầu HTML là loaded over một secure HTTPS connection, nhưng other các tài nguyên (such as images, videos, stylesheets, và scripts) là loaded over an insecure HTTP connection.»
đó matters vì insecure pieces reopen chính xác lỗ hổng HTTPS closed.
Anyone sitting on network giữa khách truy cập và máy chủ có thể đọc hoặc tamper
với những điều đó http:// các yêu cầu — so padlock trong address bar là promising nhiều hơn
security hơn trang thực ra có.
hai kinds, và Điều gì các trình duyệt làm về them
các trình duyệt không treat all mixed nội dung giống nhau. họ loại nó by Cách nhiều damage insecure tài nguyên có thể làm:
- Active mixed nội dung — scripts, stylesheets, và iframes. Những có thể control đó toàn bộ trang, so một tampered một có thể rewrite mọi thứ. Các trình duyệt block điều này. Này là điều gì thực ra breaks của bạn layout, của bạn interactivity, hoặc một toàn bộ embedded widget sau một migration.
- Passive mixed nội dung — images, audio, và video. Những không thể take over đó trang, so các trình duyệt có trong lịch sử loaded them nhưng taken away đó padlock và shown một “not fully secure” (bản dịch) «không fully secure» warning. đó là thay đổi — modern các trình duyệt increasingly upgrade hoặc block những cũng.
Một điều Đó là không mixed nội dung: đơn giản link (<a href="http://…">) để
HTTP trang. đó chỉ navigates bạn nơi nào đó; nó không load insecure piece vào
của bạn secure trang.
Cách khắc phục nó
khắc phục là gần như luôn giống nhau: làm insecure tài nguyên load over HTTPS.
Thay đổi http:// để https:// trong reference, hoặc sử dụng path đó không hard-code
giao thức tại all. phần lớn của time tài nguyên là đã khả dụng over HTTPS —
ai đó chỉ left old http:// URL trong template, plugin, hoặc database.
nếu bạn muốn safety net cho bất cứ điều gì bạn missed, Bạn có thể thêm single line của
configuration — upgrade-insecure-requests header — đó tells trình duyệt để
âm thầm rewrite leftover http:// tài nguyên các yêu cầu để https:// trước khi nó gửi
them. nó great backstop, nhưng nó không reason để skip cleaning lên thực
nguồn. Evidence for this claim The upgrade-insecure-requests CSP directive rewrites insecure URLs as secure URLs before requests are made. Scope: MDN documents the directive's rewriting behavior and limits; it does not guarantee that an HTTPS version of every resource exists. Confidence: high · Verified: MDN: CSP upgrade-insecure-requests
Muốn đầy đủ picture — chính xác tài nguyên lists các trình duyệt block, Cách detect
mixed nội dung tại quy mô với DevTools console và CSP các báo cáo,
upgrade-insecure-requests và block-all-mixed-content directives, Vì sao của bạn CMS
giữ reintroducing nó, và Cách mixed nội dung interacts với HSTS? Chuyển để
Nâng cao tab.
TL;DR — Mixed nội dung là an HTTPS trang loading một sub-tài nguyên over HTTP. Đó hiện tại trình duyệt/W3C taxonomy sorts này vào upgradable và blockable nội dung; đó older active/passive split (dùng dưới as một blast-radius cách diễn đạt) vẫn tracks đó divide cho hầu hết tài nguyên types, với exceptions — CORS-enabled images,
srcset/picturecandidates, và IP-host các yêu cầu là blockable mặc dù một đơn giảnimg srclà upgradable. Active (scripts, stylesheets, iframes,XMLHttpRequest/fetch, và bất cứ điều gì đó trình duyệt executes) là blocked — một tampered script có thể rewrite đó trang — so đây là đó launch-day regression để cách sửa đầu tiên. Passive (images, audio, video) trong lịch sử loaded với một downgraded indicator và là hiện tại increasingly auto-upgraded hoặc blocked. Anchor links và other top-cấp độ HTTP navigation không mixed nội dung; neither là insecure downloads, mà là một related nhưng tách biệt boundary. Detect điều này trên three layers — fetched nguồn, được kết xuất/runtime state, và real người dùng sessions — by crawling đó HTTPS site, reading đó Chrome DevTools console (chính xác wording là trình duyệt/version cụ thể), hoặc collectingContent-Security-Policy-Report-Onlyviolations; cách sửa điều này by confirming an HTTPS tương đương thực ra hoạt động, thì pointing mỗi sub-tài nguyên tạihttps://(relative/giao thức-relative paths là fine khi bạn đã verified quyền sở hữu và base-URL behavior, không một universal default).Content-Security-Policy: upgrade-insecure-requestsrewrites trong-phạm vihttp://sub-tài nguyên các yêu cầu (including cross-origin ones) đểhttps://trước họ là đã gửi và trước mixed-nội dung/CSP kiểm tra chạy — một net, không một substitute cho sửa đó nguồn, với không HTTP fallback nếu đó upgrade fails, và điều này làm không upgrade top-cấp độ navigation để bên thứ ba origins, so điều này không replace HSTS. Putting đó directive itself trong báo cáo-chỉ chế độ là một không-op — monitor với một tách biệt báo cáo-chỉ policy thay vì. CMS databases (lại lên và dry-chạy bất kỳ replacement — naive string-replace có thể corrupt serialized dữ liệu), plugin, themes, service workers/caches, và quảng cáo/analytics tags là đó recurring re-offenders — audit tại quy mô, không trang by trang.
HTTPS hub introduces mixed nội dung as một của hai launch-day thất bại modes của migration ( khác là các chuyển hướng). Đây là deep dive nó points để — chính xác tài nguyên tiers, detection stack, CSP directives, và operational reasons nó giữ coming lại.
Điều gì được tính as mixed nội dung — và Điều gì không
Mixed nội dung là scoped precisely: đây là về sub-các tài nguyên đó trang loads, không về links đó trang contains. Google definition: “A page has mixed content when its initial HTML is loaded over a secure HTTPS connection, but other resources (such as images, videos, stylesheets, and scripts) are loaded over an insecure HTTP connection.” (bản dịch) «MỘT trang có mixed nội dung khi của nó ban đầu HTML là loaded over một secure HTTPS connection, nhưng other các tài nguyên (such as images, videos, stylesheets, và scripts) là loaded over an insecure HTTP connection.» Evidence for this claim Mixed content occurs when a secure page loads resources over insecure HTTP, and browsers upgrade or block mixed-content requests by resource type. Scope: MDN documents current browser categories and behavior; individual browser versions may differ at the margins. Confidence: high · Verified: MDN: Mixed content
trap đó reassures mọi người falsely là anchor tag. <a href="http://…">
link để HTTP trang là không mixed nội dung — nó navigates để new document; nó
không load insecure tài nguyên vào hiện tại secure một. đó đúng của bất kỳ
top-cấp độ navigation để HTTP trang, không chỉ anchor clicks.
nó vẫn worth sending outbound links để HTTPS destinations. Dưới modern
trình duyệt-default Referrer-Policy (strict-origin-when-cross-origin), nhấp từ
HTTPS trang để HTTP đích làm drop Referer header, mà có thể mangle
referral phân tích — nhưng đó behavior là policy- và trình duyệt-phụ thuộc, không
universal rule: trang (hoặc upstream proxy/CDN) đó sets looser
Referrer-Policy có thể vẫn gửi referrer on đó downgrade. kiểm tra thực tế
Referrer-Policy trong effect trước khi asserting Cách nhiều referral dữ liệu được cho trang web
loses — nhưng trong bất kỳ case, đó tách biệt vấn đề từ mixed nội dung, không mixed
nội dung itself.
Active so với. passive: phân biệt đó sets của bạn priorities
Modern trình duyệt và W3C tài liệu classifies mixed nội dung primarily as upgradable versus blockable nội dung — tài nguyên types trình duyệt sẽ silently retry over HTTPS versus ones nó từ chối outright — thay vì older active/passive split. Active/passive là vẫn hữu ích shorthand cho Vì sao các trình duyệt draw đó line (Cách nhiều của trang tài nguyên có thể compromise), và nó Cách Google own explainer frames nó, so nó kept dưới as chính triage cách diễn đạt — chỉ không treat nó as hiện tại chính thức taxonomy Khi bạn cần reason về cụ thể tài nguyên loại; see exceptions sau khi hai lists.
Các trình duyệt classify mixed nội dung by cách nhiều of đó trang đó insecure tài nguyên có thể compromise. Google: “Active mixed content poses a greater threat than passive mixed content.” (bản dịch) «Active mixed nội dung poses một greater threat hơn passive mixed nội dung.» Đó single sentence nên drive của bạn triage order.
Active mixed nội dung interacts với — và có thể take over — đó toàn bộ trang. Google mô tả điều này as “scripts, stylesheets, iframes, and any other code the browser can download and execute.” (bản dịch) «scripts, stylesheets, iframes, và bất kỳ other code đó trình duyệt có thể download và execute.» Trong thực tế đó active list là:
<script src="http://…">— worst case; intercepted script có thể rewrite đểàn bộ DOM, exfiltrate form dữ liệu, hoặc inject nội dung.<link rel="stylesheet" href="http://…">— CSS có thể hide, reposition, hoặc overlay bất cứ điều gì, so nó được xem như active.<iframe src="http://…">— embedded insecure document bên trong của bạn secure một.XMLHttpRequest/fetch()đểhttp://— insecure dữ liệu trang sau đó acts on.- Web fonts,
<object>/<embed>các tài nguyên, và<link>variants đó pull trong executable hoặc layout-controlling nội dung.
Vì một tampered active tài nguyên có thể rewrite đó trang, “Most browsers already block this type of content by default to protect users.” (bản dịch) «Hầu hết các trình duyệt đã block này loại of nội dung theo mặc định để bảo vệ người dùng.» đó là vì sao active mixed nội dung là điều gì visibly breaks điều sau một migration — một blocked stylesheet strips của bạn CSS, một blocked script kills interactivity, một blocked iframe leaves một lỗ hổng. Cách sửa active đầu tiên. đây là một functional bug, không chỉ một security nag.
Passive (display) mixed nội dung — Google: “including images, video, and audio” (bản dịch) «including images, video, và audio» — “doesn’t interact with the rest of the page.” (bản dịch) «không interact với đó rest of đó trang.» An intercepted image có thể là đã đổi nhưng không thể seize đó document. So trong lịch sử các trình duyệt loaded điều này và chỉ downgraded đó indicator: “Until recently, passive mixed content was loaded in all browsers, because blocking it would have broken many websites. This is now beginning to change.” (bản dịch) «Until recently, passive mixed nội dung đã là loaded trong all các trình duyệt, vì blocking điều này sẽ có hỏng nhiều websites. Này là hiện tại beginning để thay đổi.» Đó direction of travel trên các trình duyệt là toward auto-upgrading passive các tài nguyên để HTTPS nơi có thể và blocking điều gì không thể là upgraded, so “passive = harmless” (bản dịch) «passive = harmless» là không lâu hơn một safe assumption để xây dựng on.
Exceptions active/passive split không capture
Đó upgradable/blockable line có several exceptions đó không follow đó chung “images upgrade, scripts block” (bản dịch) «images upgrade, scripts block» pattern trên — những là đó cases đó thực ra trip mọi người lên trong thực tế:
- CORS-enabled image các yêu cầu là force-failed, không upgraded. An ordinary
<img src="http://…">là upgradable, nhưng an image yêu cầu đã làm vớicrossoriginset là treated differently by đó mixed-nội dung algorithm và fails thay vì silently upgrading. srcsetvà<picture>candidates là blockable, không upgradable. Đó giống nhau image, requested qua một responsive-image mechanism thay vì một đơn giảnsrc, falls vào đó blockable category — không assume mỗi image reference behaves đó giống nhau way.- IP-address hosts là blocked, không upgraded, ngay cả cho an nếu không-upgradable
tài nguyên loại. MỘT reference như
http://203.0.113.5/logo.pngkhông nhận đó tự động-upgrade treatment một domain-hosted tương đương sẽ. - Nested contexts và workers là trong phạm vi. Mixed-nội dung kiểm tra apply bên trong iframes và bên trong service/shared workers cũng, không chỉ đó top document — một worker fetching an insecure script là vẫn mixed nội dung.
- Local và loopback origins có của họ own nuance.
localhost, loopback addresses, vàfile://contexts là “potentially trustworthy origins” (bản dịch) «potentially trustworthy origins» dưới đó spec ngay cả không có TLS, so một đơn giản HTTP-so với-HTTPS heuristic không map cleanly onto local development environments. - Insecure downloads là một related nhưng tách biệt boundary. MỘT download initiated
từ một secure trang over
http://là một real risk, nhưng đây là governed by của nó own download-security xử lý, không đó sub-tài nguyên mixed-nội dung rules trong này section. - Top-cấp độ HTTP navigation vẫn không mixed nội dung, including đó anchor-link case trên — đó là một thuộc tính of navigation, không of một loaded sub-tài nguyên, tuy nhiên nhiều of những other exceptions apply.
Detecting mixed nội dung — toàn bộ stack
có không single button, và mỗi layer dưới các câu trả lời khác câu hỏi — sạch kết quả tại một layer không clear others. Diagnose fetched nguồn (Điều gì thô HTML thực ra references), được kết xuất/runtime state (Điều gì trình duyệt các yêu cầu sau khi nó parsed trang và chạy của nó scripts), và thực người dùng sessions (Điều gì happens cho khách truy cập behind consent banner, geo-chuyển hướng, login wall, hoặc thứ ba-party tag đó chỉ fires dưới cụ thể conditions) riêng. Layer những điều này từ “một trang” để “toàn bộ site”:
-
Đó Chrome DevTools console (được kết xuất/runtime state). Load đó HTTPS trang và open đó console. Blocked active mixed nội dung logs một message along đó lines of “Mixed Content: The page … was loaded over HTTPS, but requested an insecure … This request has been blocked; the content must be served over HTTPS.” (bản dịch) «Mixed Nội dung: Đó trang … đã là loaded over HTTPS, nhưng requested an insecure … Này yêu cầu đã được blocked; đó nội dung phải được phân phối over HTTPS.» Passive đó nhận loaded logs một warning thay vì một block. Đó Security panel (hoặc đó Các vấn đề tab) groups điều này lên theo trang. Fast cho spot-kiểm tra và cho confirming một cụ thể cách sửa — nhưng treat đó chính xác message wording, panel layout, và ngay cả mà tài nguyên types nhận blocked as trình duyệt- và version-cụ thể; này đã là confirmed so với Chrome as of 2026-07 và bạn nên verify hiện tại wording on đó thực tế trình duyệt/version bạn là diagnosing thay vì quoting điều này as một fixed UI string, và expect Firefox, Safari, và Edge để differ.
-
** trang web crawler** (fetched nguồn, tại quy mô). DevTools là theo-trang; crawl là trang web-wide. Ahrefs trang web Audit và Screaming Frog cả hai flag các trang đó reference
http://sub-các tài nguyên on HTTPS trang web — chỉ realistic way để tìm mixed nội dung trên thousands của các URL. Đây là chính tool cho audit, nhưng nó vẫn reading nguồn: crawl passing sạch không prove được kết xuất trang hoặc thực session là sạch cũng — record mà trình duyệt/tool/version produced được cho kết quả thay vì reporting một unqualified truyền/fail. -
CSP violation reporting (real người dùng sessions). Bạn có thể làm đó các trình duyệt of real khách truy cập báo cáo mixed nội dung lại để bạn, mà catches các tài nguyên đó chỉ load on certain các trang, cho certain người dùng, dưới certain consent trạng thái, hoặc từ bên thứ ba tags bạn không control — đó layer neither một crawl nor một single DevTools kiểm tra có thể reach. web.dev: “You can use content security policy to collect reports of mixed content on your site. To enable this feature, set the
Content-Security-Policy-Report-Onlydirective by adding it as a response header for your site.” (bản dịch) «Bạn có thể dùng nội dung security policy để collect các báo cáo of mixed nội dung trên trang web của bạn. Để enable này feature, set đóContent-Security-Policy-Report-Onlydirective by thêm điều này as một header phản hồi cho trang web của bạn.» Báo cáo-Chỉ chế độ các báo cáo violations không có enforcing đó policy, so bạn có thể đo lường đó vấn đề trong production trước khi bạn turn on blocking. (Đó mechanism là đó modernreport-to/Reporting-Endpointsheader, hoặc đó olderreport-uri. Note này là một khác nhau, chung-purpose báo cáo-chỉ policy hơnupgrade-insecure-requestsitself — putting đó cụ thể directive trong báo cáo-chỉ chế độ không hoạt động, as covered dưới.)
sử dụng all three: DevTools để verify được kết xuất trang, crawler để inventory fetched nguồn, CSP các báo cáo để catch thực-session dài tail đó chỉ hiển thị lên trong wild. Một crawl passing là evidence về nguồn, không bảo đảm đó mỗi consent state, quảng cáo-tech variant, personalization branch, hoặc worker là sạch.
Sửa tại nguồn
thực khắc phục bắt đầu trước khi bạn touch single reference: verify HTTPS tương đương thực ra tồn tại, presents hợp lệ certificate, và trả về nội dung bạn expect — không assume swapping scheme là safe chỉ vì domain resolves. sau khi đó confirmed, mỗi sub-tài nguyên reference nên resolve over HTTPS. Options dưới là trong rough order của preference, nhưng mỗi một vẫn phụ thuộc vào quyền sở hữu và context, không chỉ string bạn loại:
- Absolute HTTPS URLs — thay đổi
http://cdn.example.com/app.jsđểhttps://cdn.example.com/app.js. Rõ ràng và unambiguous; đó safest default khi bạn là không certain về đó serving context dưới. - Root-relative hoặc relative paths — cho các tài nguyên bạn own on đó giống nhau site,
/assets/app.jsinherits đó trang scheme tự động. Google HTTPS hướng dẫn: “Make sure intrasite URLs and external URLs don’t depend on a specific protocol. Use relative paths or leave out the protocol as in//example.com/something.js.” (bản dịch) «Hãy bảo đảm intrasite URLs và external URLs không phụ thuộc on một cụ thể giao thức. Dùng relative paths hoặc leave out đó giao thức as trong//example.com/something.js.» Treat này as conditional, không một universal khuyến nghị: điều này chỉ holds khi bạn đã confirmed bạn thực ra own đó tài nguyên (một relative path để một bên thứ ba asset không làm hợp lý), đó trang real base URL resolves đó way bạn expect (một<base>tag, một proxied path, hoặc an embedded/AMP context có thể thay đổi điều gì “relative” có nghĩa là), và đó không có gì downstream reconstructs đó URL trong một way đó reintroduceshttp://— client-side code building một URL từwindow.locationhoặc một stored absolute giá trị, ví dụ. - Giao thức-relative URLs (
//example.com/something.js) vẫn hoạt động, nhưng họ là không đó được ưu tiên universal cách sửa — gate them on đó giống nhau quyền sở hữu/base-URL kiểm tra trên, không chỉ habit. On an all-HTTPS web, an rõ rànghttps://là thường clearer và tránh surprises nếu đó file là bao giờ opened từ một non-HTTP context; reach cho giao thức-relative chỉ nơi bạn có một cụ thể reason không để hard-code đó scheme.
Tại quy mô bạn gần như không bao giờ hand-edit templates một by một — nhưng không chạy
unguarded database string-replacement so với production either. http://yourdomain
→ https://yourdomain looks như đơn giản tìm-và-replace, và cho đơn giản-text
các trường nó thường là safe, nhưng CMS nội dung có thể là serialized hoặc structured (PHP
serialized arrays, JSON blobs, block-editor dữ liệu) nơi naive substring đổi
corrupts record thay vì sửa nó. sử dụng application-aware tooling đó
understands serialization format, lại lên database đầu tiên, và
dry-chạy replacement so Bạn có thể review affected các hàng trước khi committing.
sau đó khắc phục handful của template/config files đó emit các URL; crawler và
CSP các báo cáo mop lên stragglers.
upgrade-insecure-requests: safety net (và của nó limits)
Đó proactive backstop là một Nội dung-Security-Policy directive. web.dev: “The
upgrade-insecure-requests CSP directive instructs the browser to upgrade insecure
URLs before making network requests.” (bản dịch) «Đó upgrade-insecure-requests CSP directive instructs đó trình duyệt để upgrade insecure URLs trước đang làm network các yêu cầu.» Set đó header:
Content-Security-Policy: upgrade-insecure-requestsTheo MDN, điều này “instructs user agents to treat all of a site’s insecure URLs (those served over HTTP) as though they have been replaced with secure URLs (those served over HTTPS).” (bản dịch) «instructs người dùng agents để treat all of một site insecure URLs (những phân phối over HTTP) as though they đã được replaced với secure URLs (những phân phối over HTTPS).» Concretely, MDN says điều này upgrades: “requests to load resources (such as images, scripts, or fonts),” (bản dịch) «các yêu cầu để load các tài nguyên (such as images, scripts, hoặc fonts),» “navigation requests (such as link targets) which are same-origin with the document,” (bản dịch) «navigation các yêu cầu (such as link targets) mà là giống nhau-origin với đó document,» “navigation requests in nested browsing contexts, such as iframes,” (bản dịch) «navigation các yêu cầu trong nested browsing contexts, such as iframes,» và “form submissions.” (bản dịch) «form submissions.» Evidence for this claim The upgrade-insecure-requests CSP directive rewrites insecure URLs as secure URLs before requests are made. Scope: MDN documents the directive's rewriting behavior and limits; it does not guarantee that an HTTPS version of every resource exists. Confidence: high · Verified: MDN: CSP upgrade-insecure-requests
Hai operational details quan trọng beyond đó quote. đầu tiên, sub-tài nguyên upgrade không phải limited để giống nhau-origin các yêu cầu — nó navigation upgrade đó giống nhau-origin-chỉ theo quote trên; ordinary sub-tài nguyên các yêu cầu nhận rewritten trên origins cũng, so CDN-hosted script hoặc thứ ba-party font nhận upgraded, không chỉ giống nhau-trang web assets. thứ hai, rewrite happens trước khi trình duyệt mixed-nội dung và CSP kiểm tra evaluate yêu cầu, mà là Vì sao tài nguyên đó sẽ nếu không là blocked outright as mixed nội dung có thể load cleanly sau khi nó là upgraded — upgrade pre-empts block.
Three limits bạn phải không paper over:
- Điều này không upgrade bên thứ ba top-cấp độ navigation. MDN: “However, top-level
navigation requests whose target is a different origin will not be upgraded.” (bản dịch) «Tuy nhiên, top-cấp độ navigation các yêu cầu whose đích là một khác nhau origin sẽ không là upgraded.»
Làm đó, điều này là explicitly không một replacement cho HSTS: “The
upgrade-insecure-requestsdirective will not ensure that users visiting your site via links on third-party sites will be upgraded to HTTPS for the top-level navigation and thus does not replace theStrict-Transport-Security(HSTS) header.” (bản dịch) «Đóupgrade-insecure-requestsdirective sẽ không bảo đảm đó người dùng visiting trang web của bạn qua links on bên thứ ba các trang sẽ là upgraded để HTTPS cho đó top-cấp độ navigation và thus không replace đóStrict-Transport-Security(HSTS) header.» (Hơn on đó split dưới.) - đây là một net, không một cách sửa, và điều này không fall lại. Nếu đó tài nguyên genuinely
không khả dụng over HTTPS, đó upgraded yêu cầu chỉ fails outright — điều này làm
không fall lại để đó original
http://version. Cleaning đó nguồn là vẫn đó job; đó directive covers điều gì bạn missed, không điều gì là genuinely hỏng. - Báo cáo-chỉ chế độ không perform đó upgrade — đây là một không-op. Putting
upgrade-insecure-requestsbên trong mộtContent-Security-Policy-Report-Onlyheader là đã bỏ qua by đó trình duyệt: không có gì nhận rewritten, và không có gì nhận reported cho điều này either. Nếu bạn muốn visibility vào điều gì đó upgrade sẽ ảnh hưởng trước khi bạn enforce điều này, chạy một tách biệt, chung-purpose báo cáo-chỉ policy đó các báo cáo disallowedhttp://destinations (đó giống nhaudefault-src https:báo cáo-chỉ approach dùng cho detection trên) — bạn không thể nhận đó visibility by đang làmupgrade-insecure-requestsitself báo cáo-chỉ.
block-all-mixed-content — mostly lịch sử
có một companion directive, block-all-mixed-content, mà — theo MDN —
“prevents loading any assets over HTTP when the page uses HTTPS,” (bản dịch) «ngăn loading bất kỳ assets over HTTP khi đó trang dùng HTTPS,» including “both
blockable and upgradable mixed content,” (bản dịch) «cả hai blockable và upgradable mixed nội dung,» và áp dụng để iframes cũng. Trong thực tế đây là
đã superseded. MDN marks điều này deprecated và “obsolete in the specification,” (bản dịch) «obsolete trong đó đặc tả,»
noting: “Content that isn’t blocked is now always upgraded to a secure connection, so
this directive is not needed.” (bản dịch) «Nội dung đó không blocked là hiện tại luôn upgraded để một secure connection, so này directive không phải needed.» Reach cho upgrade-insecure-requests; treat
block-all-mixed-content as legacy bạn có thể inherit, không điều gì đó để deploy new.
Nếu bạn đã gửi upgrade-insecure-requests, block-all-mixed-content có
không có gì left để làm cho upgraded các yêu cầu — đó upgrade rewrite happens đầu tiên, so by
đó time một block-all kiểm tra sẽ chạy, đó yêu cầu có đã upgraded (hoặc có
đã failed). đây là không chỉ legacy; đây là redundant wherever UIR là đã
deployed.
Vì sao của bạn CMS giữ reintroducing nó
Mixed nội dung không phải một-time cleanup — nó recurs, vì several các hệ thống âm thầm
re-inject http:// các URL sau khi bạn think bạn’re đã xong:
- ** nội dung database.** Trong WordPress, Drupal, và phần lớn CMSes, editors paste
images và embeds với absolute
http://các URL straight vào post các thân phản hồi. những điều đó trực tiếp trong database, không trong template, so code-cấp độ khắc phục không bao giờ touches them — hence DB tìm kiếm-và-replace. - Themes và plugin. theme hoặc plugin đó hard-codes
http://asset URL ( font, script, background image) reintroduces mixed nội dung on mỗi trang nó renders, và plugin cập nhật có thể bring nó lại sau khi bạn’ve cleaned nó. - Quảng cáo tech, phân tích, và thứ ba-party tags. Tag managers, quảng cáo networks, chat
widgets, và phân tích snippets load của họ own sub-các tài nguyên — và nếu vendor
tag vẫn calls
http://, nó mixed nội dung Bạn có thể’t khắc phục trong của bạn own codebase. Đây là chính xác dài tail CSP reporting là cho; durable khắc phục là pressing vendor để phục vụ over HTTPS (hoặc dropping tag). nếu vendor có không hoạt động HTTPS điểm cuối, durable choices là giống nhau three: nhận them để khắc phục nó, replace dependency, hoặc drop nó — ở đó không phải fourth option đó giữ insecure version đang chạy safely. - Service workers và caches. service worker có thể bộ nhớ đệm phản hồi (hoặc
yêu cầu itself) đó vẫn points tại
http://, và nó’ll giữ serving đó stale reference on repeat visits ngay cả sau khi bạn khắc phục nguồn. Reproduce suspected khắc phục trong incognito/uncached session trước khi concluding nó đã không hoạt động, và làm sure deploy đó thay đổi tài nguyên các URL cũng bumps service worker/bộ nhớ đệm version so stale entries nhận evicted thay vì replayed. - Hard-coded
http://trong old nội dung và email/print templates đó nhận reused.
operational takeaway: bake detection vào recurring audit (crawler + CSP các báo cáo), không launch-day checklist bạn chạy sau khi.
Cách mixed nội dung interacts với HSTS
Mixed nội dung và HSTS solve liền kề nhưng khác các vấn đề, và conflating them là phổ biến mistake:
upgrade-insecure-requestscác cách sửa sub-các tài nguyên của bạn own secure trang các yêu cầu — điều này upgrades đó images/scripts/iframes đó trang pulls trong.- HSTS (
Strict-Transport-Security) forces đó top-cấp độ navigation để của bạn site onto HTTPS — ngay cả đó very đầu tiên yêu cầu, trước bất kỳ chuyển hướng fires — và defends so với SSL-stripping. Google frames HSTS as một way để “avoid the cost of the 301 redirect” (bản dịch) «tránh đó cost of đó 301 chuyển hướng» và để “defeat attacks like SSL Stripping.” (bản dịch) «defeat attacks như SSL Stripping.»
They không substitute cho mỗi other. As MDN spells out, upgrade-insecure-requests
“will not ensure that users visiting your site via links on third-party sites will
be upgraded to HTTPS for the top-level navigation and thus does not replace the
Strict-Transport-Security (HSTS) header.” (bản dịch) «sẽ không bảo đảm đó người dùng visiting trang web của bạn qua links on bên thứ ba các trang sẽ là upgraded để HTTPS cho đó top-cấp độ navigation và thus không replace đó Strict-Transport-Security (HSTS) header.» MỘT fully hardened setup dùng cả hai:
upgrade-insecure-requests (hoặc sạch nguồn URLs) so đó secure trang có không insecure
cargo, và HSTS so không ai reaches đó site over HTTP ngay từ đầu. Và đó
thông thường HSTS caution vẫn áp dụng — Google: “Don’t enable HSTS until you’re certain
your site operation is robust enough to avoid ever deploying HTTPS with certificate
validation errors,” (bản dịch) «Không bật HSTS cho đến khi bạn chắc chắn hoạt động của trang web đủ ổn định để không bao giờ triển khai HTTPS với certificate validation các lỗi,» và preloading là close để một một-way door.
Làm mixed nội dung hurt SEO trực tiếp?
Lead với trực tiếp effects, vì họ’re ones bạn thực ra control: mixed nội dung là đầu tiên security và functional vấn đề. Blocked active mixed nội dung breaks kết xuất và interactivity outright — bị thiếu stylesheet hoặc script là thực regression regardless của Điều gì công cụ tìm kiếm làm của nó. đó reason đủ để khắc phục nó trước khi bạn think về thứ hạng tại all.
Đó SEO consequences là real nhưng conditional, không trực tiếp hoặc guaranteed. Hiện tại
chính thức Google hướng dẫn không establish sửa mixed nội dung as một trực tiếp xếp hạng
boost — đó HTTPS tín hiệu xếp hạng itself là scheme-based (liệu đó URL bắt đầu với
https://), không một sub-tài nguyên cleanliness kiểm tra, so một stray insecure image không
by itself cost bạn “the HTTPS signal.” (bản dịch) «đó HTTPS tín hiệu.» Nhưng downstream effects có thể vẫn cho thấy lên
depending on điều gì là thực ra hỏng: nếu Googlebot renders một trang whose CSS hoặc JS đã là
blocked as mixed nội dung, điều này có thể chỉ mục một hỏng hoặc incomplete version; một downgraded
security indicator có thể hurt người dùng trust, engagement, và conversions ngay cả với không
xếp hạng thay đổi tại all; và Google chung preference cho HTTPS canonicals là
itself conditional — không hợp lệ certificates, insecure dependencies,
HTTPS-để-HTTP các chuyển hướng, hoặc conflicting các tín hiệu canonical elsewhere on đó trang có thể
all thay đổi mà URL nhận chosen, independent of mixed nội dung cụ thể. Treat
kết xuất, lập chỉ mục, canonicalization, và analytics effects as điều để verify on
của bạn own các trang, không universal outcomes để promise — và cách sửa mixed nội dung cho đó
security và functional reasons đầu tiên.
điều này sits bên trong rộng hơn HTTPS Đối với SEO topic, mà covers migration playbook, xếp hạng-tín hiệu weight, và HSTS trong đầy đủ; nếu bạn’re cũng gỡ lỗi certificate itself (chain các lỗi, expiry, DV/OV/EV), đó sibling deep dive.
AI summary
condensed take on Nâng cao version:
- Mixed nội dung = HTTPS trang loading sub-tài nguyên over HTTP. nó về các tài nguyên trang loads, không links nó contains — anchor để HTTP trang (hoặc bất kỳ top-cấp độ HTTP navigation) là không mixed nội dung, và neither là insecure download ( related nhưng tách biệt boundary).
- hiện tại taxonomy là upgradable/blockable; active/passive là older nhưng vẫn-
hữu ích blast-radius cách diễn đạt. Active (scripts, stylesheets, iframes,
XMLHttpRequest/fetch— bất cứ điều gì trình duyệt executes) là blocked vì tampered script có thể rewrite trang; nó launch-day regression, khắc phục nó đầu tiên. Passive (images, audio, video) trong lịch sử loaded với downgraded padlock và là hiện tại increasingly auto-upgraded hoặc blocked. Exceptions để chung pattern: CORS-enabled image các yêu cầu là force-thất bại thay vì upgraded,srcset/<picture>candidates là blockable (không upgradable) như đơn giảnimg srclà, IP-address hosts là blocked thay vì upgraded, và nested contexts/workers và local/loopback origins có của họ own nuances. - Detect trên three layers, không một: fetched nguồn ( crawler như Ahrefs
trang web Audit hoặc Screaming Frog, trang web-wide), được kết xuất/runtime state ( Chrome
DevTools console/Security panel, theo-trang — chính xác wording là trình duyệt/version
cụ thể, confirmed so với Chrome as của 2026-07), và thực người dùng sessions
(
Content-Security-Policy-Report-Onlyviolation các báo cáo, production dài tail including thứ ba-party tags và consent-gated các tài nguyên). sạch kết quả tại một layer không clear others. - khắc phục tại nguồn, sau khi verifying HTTPS tương đương thực ra hoạt động: point
mỗi sub-tài nguyên tại
https://; relative/giao thức-relative paths là fine chỉ sau khi bạn’ve verified quyền sở hữu và trang thực base-URL behavior, không default. Tại quy mô, lại lên database và dry-chạy bất kỳ replacement — naive string-replace có thể corrupt serialized/structured CMS dữ liệu — sau đó khắc phục remaining template/config files. Watch cho service workers/caches replaying stalehttp://references sau khi nguồn là fixed. upgrade-insecure-requests( CSP header) rewrites trong-phạm vihttp://sub-tài nguyên các yêu cầu — including cross-origin ones — đểhttps://trước khi họ’re được gửi và trước khi mixed-nội dung/CSP kiểm tra chạy, safety net với không HTTP fallback nếu upgrade fails. nó làm không upgrade top-cấp độ navigation để thứ ba-party origins, so nó là không replacement cho HSTS, và putting directive itself trong báo cáo-chỉ chế độ là không-op — monitor với tách biệt báo cáo-chỉ policy thay vì.block-all-mixed-contentlà deprecated/obsolete, và redundant sau khiupgrade-insecure-requestslà deployed ( upgrade chạy đầu tiên, so block-all có không có gì left để block).- nó recurs vì CMS database, themes/plugin, service workers/caches, và
quảng cáo/phân tích tags giữ reintroducing
http://các URL — audit on schedule, không sau khi. - SEO impact là conditional, không trực tiếp: hiện tại Google hướng dẫn không establish trực tiếp xếp hạng boost từ sửa mixed nội dung, và HTTPS tín hiệu là scheme-based. nhưng blocked active các tài nguyên có thể làm Googlebot render/chỉ mục hỏng trang, padlock downgrade costs trust, và Google HTTPS-canonical preference là itself conditional on điều như certificate validity và conflicting các tín hiệu — không bảo đảm tied để mixed nội dung cụ thể.
Tài liệu chính thức
Chính-nguồn tài liệu từ Google và trình duyệt/các tiêu chuẩn nhóm.
Google / web.dev
- Điều gì là mixed nội dung? — definition, và active so với. passive split với trình duyệt behavior.
- Sửa mixed nội dung — finding nó, sửa sub-tài nguyên các URL,
upgrade-insecure-requests, và CSP reporting. - Enable HTTPS on của bạn các máy chủ — relative/giao thức-relative các URL, HTTP
<iframe>note, và HSTS hướng dẫn. - Preventing mixed nội dung là một part của Google HTTPS hướng dẫn — xung quanh trang web-move/migration playbook mixed nội dung các cách sửa sit bên trong.
MDN / các tiêu chuẩn
- CSP:
upgrade-insecure-requests— Điều gì nó upgrades, Điều gì nó không, và Vì sao nó không replace HSTS. - CSP:
block-all-mixed-content— deprecated/obsolete blocking directive. - MDN — Mixed nội dung — trình duyệt-behavior reference cho blockable so với. upgradable nội dung.
- nội dung Security Policy (CSP) — header những điều này directives trực tiếp trong, including reporting.
Quotes từ nguồn
On—record definitions từ Google web.dev và MDN các tiêu chuẩn tài liệu. mỗi link là deep link đó jumps để quoted passage nơi nền tảng hỗ trợ nó.
Google / web.dev — Điều gì mixed nội dung là
- “A page has mixed content when its initial HTML is loaded over a secure HTTPS connection, but other resources (such as images, videos, stylesheets, and scripts) are loaded over an insecure HTTP connection.” (bản dịch) «MỘT trang có mixed nội dung khi của nó ban đầu HTML là loaded over một secure HTTPS connection, nhưng other các tài nguyên (such as images, videos, stylesheets, và scripts) là loaded over an insecure HTTP connection.» Nguồn
- “Active mixed content poses a greater threat than passive mixed content.” (bản dịch) «Active mixed nội dung poses một greater threat hơn passive mixed nội dung.» Nguồn
- Active mixed nội dung “includes scripts, stylesheets, iframes, and any other code the browser can download and execute,” (bản dịch) «bao gồm scripts, stylesheets, iframes, và bất kỳ other code đó trình duyệt có thể download và execute,» và “Most browsers already block this type of content by default to protect users.” (bản dịch) «Hầu hết các trình duyệt đã block này loại of nội dung theo mặc định để bảo vệ người dùng.» Nguồn
- Passive mixed nội dung, “including images, video, and audio,” (bản dịch) «including images, video, và audio,» “doesn’t interact with the rest of the page.” (bản dịch) «không interact với đó rest of đó trang.» Và: “Until recently, passive mixed content was loaded in all browsers, because blocking it would have broken many websites. This is now beginning to change.” (bản dịch) «Until recently, passive mixed nội dung đã là loaded trong all các trình duyệt, vì blocking điều này sẽ có hỏng nhiều websites. Này là hiện tại beginning để thay đổi.» Nguồn
Google / web.dev — detecting và sửa
- “You can use content security policy to collect reports of mixed content on your site. To enable this feature, set the
Content-Security-Policy-Report-Onlydirective by adding it as a response header for your site.” (bản dịch) «Bạn có thể dùng nội dung security policy để collect các báo cáo of mixed nội dung trên trang web của bạn. Để enable này feature, set đóContent-Security-Policy-Report-Onlydirective by thêm điều này as một header phản hồi cho trang web của bạn.» Nguồn - “The
upgrade-insecure-requestsCSP directive instructs the browser to upgrade insecure URLs before making network requests.” (bản dịch) «Đóupgrade-insecure-requestsCSP directive instructs đó trình duyệt để upgrade insecure URLs trước đang làm network các yêu cầu.» Nguồn - “Make sure intrasite URLs and external URLs don’t depend on a specific protocol. Use relative paths or leave out the protocol as in
//example.com/something.js.” (bản dịch) «Hãy bảo đảm intrasite URLs và external URLs không phụ thuộc on một cụ thể giao thức. Dùng relative paths hoặc leave out đó giao thức as trong//example.com/something.js.» Nguồn
MDN — upgrade-insecure-requests và của nó limits
- “The HTTP Content-Security-Policy (CSP)
upgrade-insecure-requestsdirective instructs user agents to treat all of a site’s insecure URLs (those served over HTTP) as though they have been replaced with secure URLs (those served over HTTPS).” (bản dịch) «Đó HTTP Nội dung-Security-Policy (CSP)upgrade-insecure-requestsdirective instructs người dùng agents để treat all of một site insecure URLs (những phân phối over HTTP) as though they đã được replaced với secure URLs (những phân phối over HTTPS).» Nguồn - “However, top-level navigation requests whose target is a different origin will not be upgraded.” (bản dịch) «Tuy nhiên, top-cấp độ navigation các yêu cầu whose đích là một khác nhau origin sẽ không là upgraded.» Nguồn
- “The
upgrade-insecure-requestsdirective will not ensure that users visiting your site via links on third-party sites will be upgraded to HTTPS for the top-level navigation and thus does not replace theStrict-Transport-Security(HSTS) header.” (bản dịch) «Đóupgrade-insecure-requestsdirective sẽ không bảo đảm đó người dùng visiting trang web của bạn qua links on bên thứ ba các trang sẽ là upgraded để HTTPS cho đó top-cấp độ navigation và thus không replace đóStrict-Transport-Security(HSTS) header.» Nguồn
MDN — block-all-mixed-content là legacy
- “The HTTP Content-Security-Policy (CSP)
block-all-mixed-contentdirective prevents loading any assets over HTTP when the page uses HTTPS.” (bản dịch) «Đó HTTP Nội dung-Security-Policy (CSP)block-all-mixed-contentdirective ngăn loading bất kỳ assets over HTTP khi đó trang dùng HTTPS.» Nhưng điều này là marked deprecated và “obsolete in the specification,” (bản dịch) «obsolete trong đó đặc tả,» vì “Content that isn’t blocked is now always upgraded to a secure connection, so this directive is not needed.” (bản dịch) «Nội dung đó không blocked là hiện tại luôn upgraded để một secure connection, so này directive không phải needed.» Nguồn
Mixed-nội dung checklist
Chạy điều này during và sau khi HTTP→HTTPS migration, sau đó on recurring basis:
Tìm điều này
- Loaded key templates (home, sản phẩm, bài viết, checkout) over HTTPS với đó Chrome DevTools console open và noted mỗi “Mixed Content” (bản dịch) «Mixed Nội dung» message.
- Ran một đầy đủ crawl (Ahrefs Site Audit hoặc Screaming Frog) và pulled đó list
of các trang referencing
http://sub-các tài nguyên. - Set
Content-Security-Policy-Report-Onlyvới một reporting endpoint để catch đó production dài tail (theo-người dùng, theo-trang, và bên thứ ba tags).
khắc phục nó (active đầu tiên)
- All active references fixed:
<script>,<link rel="stylesheet">,<iframe>,fetch/XMLHttpRequest, fonts — những điều này là blocked, so họ break trang. - All passive references fixed:
<img>,<audio>,<video>, và của họ<source>/poster các URL. - CMS database replacement (
http://yourdomain→https://yourdomain) cho pasted nội dung — được hỗ trợ lên, dry-chạy với application-aware tooling, không thô string-replace so với serialized/structured các trường. - Theme/plugin hard-coded
http://asset các URL tìm thấy và patched. - Service worker/bộ nhớ đệm entries reproduced trong uncached session, và
bộ nhớ đệm/service-worker version bumped so stale
http://references không replay. - thứ ba-party tags (quảng cáo, phân tích, chat, embeds) confirmed để load over HTTPS — hoặc vendor pushed / tag dropped.
Backstop và verify
-
Content-Security-Policy: upgrade-insecure-requestsheader đặt as safety net (understanding nó làm không replace HSTS). - Re-được crawl và re-checked console — zero blocked active các tài nguyên, sạch padlock on checked các trang.
- Mixed-nội dung detection đã thêm để recurring audit, không chỉ launch checklist (plugin cập nhật và new nội dung reintroduce nó).
Mà khắc phục làm điều này mixed-nội dung case cần?
Hoạt động xuống từ symptom.
là insecure điều tài nguyên trang loads, hoặc link trang contains?
- link (
<a href="http://…">) → không mixed nội dung. Leave nó (tùy chọn point nó tại HTTPS cho referral-dữ liệu cleanliness). Dừng ở đây. - loaded tài nguyên (script, style, iframe, image, font, media,
fetch) → giữ going.
là tài nguyên khả dụng over HTTPS?
- Có, và bạn’ve verified nó (hợp lệ cert, trả về dự kiến nội dung) →
thay đổi reference để
https://( safe default), hoặc relative / giao thức-relative path chỉ nếu bạn own tài nguyên và có checked trang base-URL behavior. Đây là thực khắc phục. Đã xong. - Không / unsure → là nó đầu tiên-party (của bạn own asset)?
- đầu tiên-party → phục vụ nó over HTTPS (nó của bạn máy chủ; Bạn có thể). sau đó khắc phục reference as trên.
- thứ ba-party ( vendor tag, quảng cáo, embed) → ask vendor cho HTTPS điểm cuối;
nếu họ không có một, replace hoặc drop tag.
upgrade-insecure-requestssẽ try để upgrade nó, nhưng nếu vendor có không HTTPS version upgraded yêu cầu chỉ fails.
là nó active hoặc passive?
- Active (script / stylesheet / iframe /
fetch/ font) → highest priority — nó blocked, so trang là functionally hỏng cho đến khi bạn khắc phục nó. - Passive (image / audio / video) → khắc phục nó cũng, nhưng nó thấp hơn urgency (padlock downgrade / có thể tương lai block, không immediate break).
Làm bạn muốn safety net cho whatever bạn missed?
- đặt
Content-Security-Policy: upgrade-insecure-requests. Remember: net, không substitute — và nó không cover thứ ba-party top-cấp độ navigation, so nó là không stand-trong cho HSTS.
Làm bạn cũng cần để force top-cấp độ trang onto HTTPS cho đầu tiên-time / thứ ba-party referrals?
- đó HSTS, tách biệt control. Thêm
Strict-Transport-Security— nhưng chỉ sau khi của bạn certificate operation là rock-solid, vì HSTS (especially preload) là close để một-way door.
mental models
1. các tài nguyên, không links. Mixed nội dung là về Điều gì secure trang loads, không bao giờ về nơi nó links. nếu Bạn có thể’t quyết định liệu điều gì đó được tính, ask: làm trình duyệt fetch điều này để xây dựng hiện tại trang? Có → có thể mixed nội dung. nó chỉ takes me để một trang → không mixed nội dung.
2. Triage by Điều gì trình duyệt làm, không by severity trong abstract. Active (scripts, styles, iframes) là blocked → nó functional bug, khắc phục đầu tiên. Passive (images, media) là warned/upgraded → khắc phục tiếp theo. trình duyệt own behavior là của bạn priority queue.
3. Detection là funnel: verify → inventory → catch tail. DevTools console (một trang, chính xác), crawler (toàn bộ trang web, bulk), CSP các báo cáo (production, thứ ba-party, theo-người dùng dài tail). Không single tool sees all three.
4. khắc phục nguồn; net rest.
Sạch thực tế các URL — DB, templates, tags. sau đó thêm
upgrade-insecure-requests as backstop cho Điều gì slips qua. directive là
insurance, không repair.
5. Hai khác “force HTTPS” jobs, hai khác tools.
upgrade-insecure-requests upgrades sub-các tài nguyên của bạn secure trang các yêu cầu.
HSTS forces top-cấp độ navigation để của bạn trang web onto HTTPS. họ không
overlap và một không bao giờ replaces khác — hardened trang web dùng cả hai.
6. nó recurring audit, không một-time task.
CMS database, plugin/theme cập nhật, và thứ ba-party tags giữ reintroducing
http://. Treat detection as scheduled sweep, hoặc nó silently xuất hiện lại.
Mixed-nội dung anti-patterns
Mistakes đó leave insecure nội dung trực tiếp — hoặc paper over nó thay vì sửa nó.
- Treating
upgrade-insecure-requestsas đó cách sửa. đây là một net. Nếu đó tài nguyên có không HTTPS version đó upgraded yêu cầu fails, và bạn đã hidden một hỏng dependency thay vì resolving điều này. Sạch đó nguồn URLs; dùng đó directive cho đó tail. - Assuming một code deploy cleaned đó database. Trong một CMS, hầu hết
http://image và embed URLs trực tiếp trong nội dung các hàng, không templates. MỘT template cách sửa leaves mỗi old post mixed. Chạy đó DB tìm kiếm-và-replace. - Deprioritizing active mixed nội dung vì “it’s just a warning.” (bản dịch) «đây là chỉ một warning.» Điều này không — active là blocked. MỘT blocked stylesheet hoặc script là một functional outage, không một cosmetic nag.
- Spot-kiểm tra đó homepage và calling điều này đã xong. Mixed nội dung hides on sản phẩm các trang, old blog posts, và paths chỉ some người dùng hit. Crawl đó toàn bộ site và dùng CSP reporting cho điều gì đó crawl không thể reach.
- Ignoring bên thứ ba tags. An quảng cáo, analytics, hoặc chat vendor vẫn calling
http://là mixed nội dung bạn không thể cách sửa trong của bạn own repo. Chasing điều này trong của bạn codebase forever là wasted effort — push đó vendor hoặc drop đó tag. - Dùng
block-all-mixed-contenton một new xây dựng. đây là deprecated và obsolete. Reach choupgrade-insecure-requeststhay vì. - Confusing
upgrade-insecure-requestsvới HSTS. Một upgrades sub-các tài nguyên; đó other forces top-cấp độ HTTPS và defends so với SSL stripping. Shipping một và assuming bạn đã covered đó other leaves một real khoảng trống. - Leaving detection out of đó recurring audit. Sửa điều này khi và không bao giờ kiểm tra
again bảo đảm một plugin cập nhật hoặc một pasted
http://image brings điều này lại unnoticed.
Mixed nội dung — bảng tra nhanh
Active so với. passive
| Loại | Ví dụ các tài nguyên | trình duyệt behavior | Priority |
|---|---|---|---|
| Active | <script>, <link rel="stylesheet">, <iframe>, fetch/XMLHttpRequest, fonts, <object> | Blocked — breaks trang | khắc phục đầu tiên |
| Passive | <img>, <audio>, <video> và của họ sources | Warns / downgrades padlock; increasingly auto-upgraded hoặc blocked | khắc phục tiếp theo |
Anchor link <a href="http://…"> | ( navigation, không sub-tài nguyên) | không mixed nội dung tại all | N/ |
Detection stack
| Layer | Tool | Sees |
|---|---|---|
| Theo trang | Chrome DevTools console / Security panel | Chính xác blocked + warned các tài nguyên on open trang |
| Toàn bộ trang web | Ahrefs trang web Audit, Screaming Frog | mỗi trang referencing http:// sub-các tài nguyên |
| Production tail | Content-Security-Policy-Report-Only + reporting điểm cuối | Theo-người dùng, theo-trang, và thứ ba-party-tag violations |
** CSP directives**
| Directive | Điều gì nó làm | Status |
|---|---|---|
upgrade-insecure-requests | Rewrites trong-phạm vi http:// sub-tài nguyên các yêu cầu để https:// trước khi sending | hiện tại — một để sử dụng |
block-all-mixed-content | Chặn all HTTP assets on HTTPS trang | Deprecated / obsolete |
Content-Security-Policy-Report-Only | Các báo cáo violations không có enforcing | hiện tại — sử dụng để đo lường đầu tiên |
không-confuse-những điều này
| Các cách sửa | Phạm vi | |
|---|---|---|
upgrade-insecure-requests | Sub-các tài nguyên secure trang loads | giống nhau-origin + trong-phạm vi; không thứ ba-party top-cấp độ nav |
HSTS (Strict-Transport-Security) | Top-cấp độ navigation để của bạn trang web | Forces HTTPS ngay cả on đầu tiên yêu cầu; không mixed-nội dung khắc phục |
Một-liner khắc phục (CMS): DB tìm kiếm-và-replace http://yourdomain → https://yourdomain, sau đó patch templates/plugin, sau đó đặt upgrade-insecure-requests.
tìm mixed nội dung — snippets
1. Crawl một trang từ command line
Grab trang và flag bất kỳ insecure src/href sub-các tài nguyên left trong HTML.
macOS / Linux
# Flag insecure script/img/link/iframe/source references on a single URL
curl -s https://example.com/ \
| grep -Eo '(src|href)="http://[^"]+"' \
| sort -uWindows (PowerShell)
(Invoke-WebRequest -Uri "https://example.com/").Content `
| Select-String -Pattern '(src|href)="http://[^"]+"' -AllMatches `
| ForEach-Object { $_.Matches.Value } | Sort-Object -Uniqueđiều này chỉ sees thô HTML — các tài nguyên injected by JavaScript sẽ không hiển thị lên, mà là chính xác Vì sao bạn cũng sử dụng DevTools và thực crawler.
2. Chrome DevTools Console — list insecure các tài nguyên on được kết xuất trang
Paste vào console on HTTPS trang để catch ngay cả JS-inserted references:
// Every element with an http:// resource attribute in the live DOM
[...document.querySelectorAll('[src],[href],[srcset],[data-src]')]
.filter(el => /^http:\/\//.test(
el.src || el.href || el.getAttribute('srcset') || el.getAttribute('data-src') || ''
))
.map(el => ({ tag: el.tagName, url: el.src || el.href }));Đó trình duyệt cũng logs blocked active mixed nội dung on của nó own as
Mixed Content: … This request has been blocked; the content must be served over HTTPS. — đọc những đầu tiên.
3. Bookmarklet — một-nhấp console dump
Save as bookmark; nhấp nó on bất kỳ HTTPS trang để console-log của nó http://
references:
javascript:(()=>{const h=[...document.querySelectorAll('[src],[href]')].filter(e=>/^http:\/\//.test(e.src||e.href)).map(e=>e.src||e.href);console.log('%cMixed content candidates:','font-weight:bold',h.length);h.forEach(u=>console.log(u));})();4. Turn on CSP reporting (detect trong production)
Thêm báo cáo-chỉ header so thực khách truy cập’ các trình duyệt tell bạn về violations — including thứ ba-party tags và các trang của bạn crawl misses:
Content-Security-Policy-Report-Only: default-src https:; report-uri /csp-report-endpointBáo cáo-chỉ các báo cáo không có enforcing, so Bạn có thể size vấn đề safely trước khi
switching on upgrade-insecure-requests hoặc enforcement. ( modern tương đương dùng
report-to với Reporting-Endpoints header.)
5. safety-net header (sau khi bạn’ve fixed nguồn)
Content-Security-Policy: upgrade-insecure-requestsRemember nó không upgrade thứ ba-party top-cấp độ navigation và là không replacement cho HSTS.
Recurring mixed-nội dung audit SOP
Chạy điều này sau khi HTTPS launches, CMS hoặc theme releases, tag-manager thay đổi, và on regular schedule cho các trang whose nội dung thay đổi frequently.
- Crawl HTTPS các trang trong thô và được kết xuất modes. Export insecure các URL từ
src,srcset, stylesheet, iframe, media, và fetch/XHR các yêu cầu; ordinary HTTP anchor links không phải mixed nội dung. - Collect trình duyệt evidence. Review DevTools on representative templates và sử dụng
Content-Security-Policy-Report-Onlyđể capture violations triggered by thực khách truy cập và thứ ba-party tags. - Classify mỗi finding. Mark nó active hoặc passive, đầu tiên-party hoặc thứ ba-party, static hoặc JavaScript-injected, và identify template, database trường, plugin, tag, hoặc vendor đó owns nguồn.
- khắc phục nguồn reference. Point nó để hoạt động HTTPS tài nguyên hoặc safe
relative URL. không assume thay đổi
http://đểhttps://là đủ; verify đích thực ra hỗ trợ TLS. - sử dụng CSP as safety net. Thêm
upgrade-insecure-requestschỉ sau khi reviewing findings. nó có thể reduce exposure, nhưng nó không repair CMS record hoặc replace HSTS. - Re-crawl và render. Active mixed-nội dung các lỗi nên là zero on tested templates; passive các tài nguyên nên cũng resolve over HTTPS không có fallback.
- Ngăn recurrence. đúng originating template hoặc editor workflow, retain báo cáo-chỉ collection nơi appropriate, và assign new violations để hệ thống owner.
Symptom → có khả năng nguyên nhân → khắc phục
| Symptom | có khả năng nguyên nhân | Điều gì để inspect | khắc phục |
|---|---|---|---|
| trang loses layout hoặc interaction sau khi HTTPS launch | Blocked active nội dung, thường stylesheet, script, iframe, hoặc fetch yêu cầu | DevTools Console và Network các lỗi on affected template | Move tài nguyên để hợp lệ HTTPS URL và đúng nguồn template hoặc tag |
| Padlock hoặc security indicator là downgraded trong khi trang vẫn looks usable | Passive image, audio, video, hoặc khác upgradable nội dung | Được kết xuất DOM, srcset, lazy-load các thuộc tính, CSS, và trình duyệt warnings | Replace mỗi insecure tài nguyên reference và verify HTTPS asset trả về successfully |
| Vấn đề trả về sau khi CMS phát hành | absolute HTTP URL vẫn trong database, theme, plugin, hoặc generated nội dung | So sánh new violations by template và deployment; tìm kiếm stored các trường và configuration | khắc phục generator hoặc stored giá trị, sau đó backfill affected nội dung |
| Crawl là sạch nhưng thực người dùng vẫn báo cáo failures | JavaScript, consent logic, quảng cáo tech, hoặc thứ ba-party tag injects yêu cầu chỉ tại runtime | CSP báo cáo-chỉ events và DevTools với relevant consent/device state | Thay đổi hoặc xóa responsible tag/vendor configuration và retest đó state |
upgrade-insecure-requests là present nhưng tài nguyên vẫn fails | HTTP origin có không hoạt động HTTPS tương đương, hoặc policy không cover đó navigation | Upgraded yêu cầu cuối URL, certificate, và phản hồi | Host asset on HTTPS hoặc replace nó; không treat directive as proxy |
Mixed-nội dung phát hành các kiểm thử
Kiểm thử 1: được kết xuất template sweep
- Purpose: Catch active và passive các tài nguyên đó thô HTML alone misses.
- Phương thức: Render representative URL từ mỗi template và interaction state; inspect Console và Network output cho insecure hoặc blocked các yêu cầu.
- Dự kiến kết quả: Không sub-tài nguyên là requested over HTTP và không active nội dung là blocked.
- thất bại trigger: bất kỳ mixed-nội dung warning, auto-upgrade thất bại, hoặc bị thiếu layout/function gây ra by blocked tài nguyên.
- tiếp theo hành động: Trace yêu cầu để của nó template, tag, plugin, hoặc stored trường; khắc phục nguồn và rerun sweep.
Kiểm thử 2: nguồn và CSP so sánh
- Purpose: Detect violations introduced chỉ cho thực khách truy cập hoặc by thứ ba parties.
- Phương thức: So sánh crawler findings với
Content-Security-Policy-Report-Onlyevents, grouped by blocked URL, trang template, directive, và owner. - Dự kiến kết quả: Không unexplained production-chỉ violations vẫn; known noise là được ghi lại và excluded narrowly.
- thất bại trigger: repeatable violation absent từ crawl hoặc unowned thứ ba-party nguồn.
- tiếp theo hành động: Reproduce khách truy cập state và đúng hoặc xóa injecting integration.
Kiểm thử 3: recurrence kiểm thử sau khi xuất bản
- Purpose: Verify CMS không lâu hơn generates new insecure references.
- Phương thức: Publish kiểm thử item qua thông thường editorial workflow, sau đó crawl và render nó với giống nhau kiểm tra được sử dụng cho production.
- Dự kiến kết quả: Generated markup và loaded các tài nguyên sử dụng hợp lệ HTTPS các URL.
- thất bại trigger: new trang recreates HTTP reference previously cleaned từ older nội dung.
- tiếp theo hành động: khắc phục editor default, template, plugin, hoặc nội dung transform trước khi phát hành proceeds.
các tài nguyên worth của bạn time
My speaking
- Tốt hơn Safe hơn Sorry với HTTPS — SMX East 2016 (SlideShare) — my deep-dive on TLS, phổ biến HTTPS implementation failures, và migration gotchas đó produce mixed nội dung trong đầu tiên place. (Standing disclaimer: nó my understanding của những điều này các hệ thống, và adoption số liệu trong nó là từ 2016.)
My related writing
- Người mới bắt đầu Hướng dẫn để kỹ thuật SEO — nơi HTTPS và mixed nội dung fit trong bigger kỹ thuật picture.
từ khoảng ngành
- Điều gì là mixed nội dung? (web.dev / Google) — canonical definition và active-so với-passive split.
- Sửa mixed nội dung (web.dev / Google) — step-by-step: finding nó, sửa sub-tài nguyên các URL,
upgrade-insecure-requests, và CSP reporting. - MDN —
upgrade-insecure-requests— precisely Điều gì nó upgrades, Điều gì nó không, và Vì sao nó không replace HSTS. - MDN —
block-all-mixed-content— deprecated blocking directive, cho Khi bạn inherit nó. - MDN — Mixed nội dung — trình duyệt-behavior reference cho blockable so với. upgradable các tài nguyên.
- Enable HTTPS on của bạn các máy chủ (web.dev / Google) — relative/giao thức-relative các URL và xung quanh HTTPS setup hướng dẫn.
Số liệu worth citing
- Active mixed nội dung là blocked theo mặc định. Google: “Most browsers already block this type of content by default to protect users.” (bản dịch) «Hầu hết các trình duyệt đã block này loại of nội dung theo mặc định để bảo vệ người dùng.» — đó reason active mixed nội dung là một functional outage, không một warning. Nguồn
- Active mixed nội dung là đó greater threat. Google own xếp hạng of đó hai tiers: “Active mixed content poses a greater threat than passive mixed content.” (bản dịch) «Active mixed nội dung poses một greater threat hơn passive mixed nội dung.» — right-sizes của bạn triage order. Nguồn
- Passive mixed nội dung là không lâu hơn safely “được phép.” Google: “Until recently, passive mixed content was loaded in all browsers … This is now beginning to change.” (bản dịch) «Until recently, passive mixed nội dung đã là loaded trong all các trình duyệt … Này là hiện tại beginning để thay đổi.» — đó “images are harmless” (bản dịch) «images là harmless» assumption là expiring. Nguồn
upgrade-insecure-requestskhông phải một substitute cho HSTS. MDN trạng thái điều này plainly: điều này “does not replace theStrict-Transport-Security(HSTS) header.” (bản dịch) «không replace đóStrict-Transport-Security(HSTS) header.» — đó hai controls solve khác nhau halves of đó vấn đề. Nguồn- ~89% of đó web là on HTTPS (W3Techs, 2026; xác nhận đó hiện tại hình), mà
là chính xác vì sao leftover
http://sub-các tài nguyên on an nếu không-secure trang là đó phổ biến chế độ lỗi hiện tại — đó các trang là HTTPS; đó cargo lags behind. Context qua đó HTTPS hub.
Tự kiểm tra: Mixed nội dung
Five nhanh các câu hỏi on mixed nội dung. Pick câu trả lời cho mỗi, sau đó kiểm tra.
Nhật ký thay đổi
Đã cập nhật 8 thg 8, 2026.
Tóm tắt biên tập và chi tiết thay đổi đã ghi nhận.Chi tiết thay đổi
-
Ghi chú thay đổi chi tiết hiện chỉ có bằng tiếng Anh.
Không thể so sánh đầy đủ — không có bản lưu trước đó cho lần sửa đổi này.
Đã cập nhật 17 thg 7, 2026.
Tóm tắt biên tập và chi tiết thay đổi đã ghi nhận.Chi tiết thay đổi
-
Ghi chú thay đổi chi tiết hiện chỉ có bằng tiếng Anh.
Không thể so sánh đầy đủ — không có bản lưu trước đó cho lần sửa đổi này.