nginx add_header Content-Security-Policy “upgrade-insecure-requests;connect-src *“;

编程知识 更新时间:2023-04-05 06:19:24

背景是这样 后端写了个静态网页,页面里面有对资源http的调用,导致js在请求时,报了个错

Mixed Content: The page at 'https://huangkaikang/' was loaded over HTTPS, but requested an insecure frame 'http://huangkaikang/resume/'. This request has been blocked; the content must be served over HTTPS.

类似这样,看字面意思,结合google想到这个应该可以在nginx那边加个重定向或者header来解决

遂查到了

add_header Content-Security-Policy "upgrade-insecure-requests;connect-src *";

这个加在nginx的 server块里就好了,页面中不安全的http请求会被转为https

问题的根源应该就是浏览器js的安全机制,不允许在嵌套在https的页面中进行http请求吧?大致理解是这样

更多推荐

nginx add_header Content-Security-Policy “upgrade-insecure-requests;connect-src

本文发布于:2023-04-05 06:19:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/395178c034c2a419ea8829f3a275b485.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Security   Policy   Content   nginx   add_header

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 45236文章数
  • 14阅读数
  • 0评论数