Nginx增加跨域访问限制
2022年7月29日
如果需要限制自己的网站只能访问哪些域名的话,可以通过配置Nginx来实现。配置示例如下:
1 2 3 4 5 6 7 8 9 10 |
location / { expires $expires; add_header Content-Security-Policy "default-src 'self' 'unsafe-inline' https://*.myqcloud.com https://jic.talkingdata.com https://help.yinziai.com https://*.baidu.com wss://*.crisp.chat https://*.crisp.chat blob: data: https://*.fundebug.com;"; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; add_header X-Frame-Options "SAMEORIGIN"; try_files $uri $uri/index.html @proxy;# for generate.subFolders: true # try_files $uri $uri.html @proxy; # for generate.subFolders: false } |