使用 Service Worker 阻止不安全的 http 请求
Blocking non-secure http request with service worker
我正在将网站迁移到 https,但我们的广告投放网络经常通过 http 发送不安全的广告,导致 "mixed content" 警告。 block/stub 所有的 HTTP 请求都是一个 service worker 是个好主意吗?
您可以使用 CSP 来阻止所有非 https 请求:
Content-Security-Policy: block-all-mixed-content
它将http请求重写为https。如果您只是想阻止它们,类似的方法应该有效:
Content-Security-Policy: default-src 'self' data: 'unsafe-inline' 'unsafe-eval' https:;
更多详情:https://scotthelme.co.uk/migrating-from-http-to-https-ease-the-pain-with-csp-and-hsts/
https://report-uri.io/home/generate
(我认为这比使用 Service Worker 更好...)
警告:如果滥用,CSP 可以阻止合法请求 and/or 内联 scripts/css/plugins...
我正在将网站迁移到 https,但我们的广告投放网络经常通过 http 发送不安全的广告,导致 "mixed content" 警告。 block/stub 所有的 HTTP 请求都是一个 service worker 是个好主意吗?
您可以使用 CSP 来阻止所有非 https 请求:
Content-Security-Policy: block-all-mixed-content
它将http请求重写为https。如果您只是想阻止它们,类似的方法应该有效:
Content-Security-Policy: default-src 'self' data: 'unsafe-inline' 'unsafe-eval' https:;
更多详情:https://scotthelme.co.uk/migrating-from-http-to-https-ease-the-pain-with-csp-and-hsts/
https://report-uri.io/home/generate (我认为这比使用 Service Worker 更好...)
警告:如果滥用,CSP 可以阻止合法请求 and/or 内联 scripts/css/plugins...