3
我試圖實現的目標:將頁面內的所有HTTP請求都升級到HTTPS並報告/記錄事件。內容安全策略頭 - 同時升級不安全的請求並報告事件
服務器支持HTTP和HTTPS。
測試HTML頁面。注意<img>
<html>
<head>
</head>
<body>
<img src="http://example.com/testimage.png" />
</body>
</html>
硬編碼的HTTP協議,根據該W3C documentation,我建立了我的.htaccess這樣的:
Header set Content-Security-Policy "upgrade-insecure-requests; default-src https:"
Header set Content-Security-Policy-Report-Only "default-src https:; report-uri https://report-uri.io/report/..."
當我打電話https://example.com/testpage.html,它加載圖像通過HTTPS但不報告事件。
我錯過了什麼?
您使用哪種瀏覽器?也許瀏覽器不支持它? – oreoshake
我沒有在Chrome或Firefox中看到違規報告(通過檢查開發控制檯) – oreoshake