nginx add header csp

引入谷歌 / hotjar统计,等外站的js/frame/css,会出现script-src、style-src、connect-src、frame-src、img-src等提示不安全,需要在nginx的头部增加Content-Security-Policy

支持https://*.xxx.com

add_header Content-Security-Policy "default-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' https://www.googletagmanager.com https://www.google-analytics.com https://static.hotjar.com https://script.hotjar.com https://vars.hotjar.com 'unsafe-eval' 'unsafe-inline'; connect-src 'self' https://www.google-analytics.com https://*.hotjar.com https://stats.g.doubleclick.net https://www.google.com; frame-src 'self' https://*.hotjar.com 'unsafe-eval' 'unsafe-inline'; img-src 'self' https://www.google-analytics.com https://api.qrserver.com https://www.google.com data:" always
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload" always;

add_header Content-Security-Policy "upgrade-insecure-requests;connect-src *";
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload" always;
add_header Cache-Control no-store;
add_header X-Frame-Options SAMEORIGIN;
add_header Permissions-Policy "geolocation=(),midi=(),microphone=(),camera=(),fullscreen=(self)";
add_header Referrer-Policy "no-referrer-when-downgrade";

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值