nginx - 如何在 nginx 中正确设置 X-Frame-Options Allow-From

标签 nginx cross-domain content-security-policy x-frame-options

我试图在 Nginx 中设置 ALLOWED-FROM 但到目前为止我尝试的所有设置都导致以下 Chrome 错误:Invalid 'X-Frame-Options' header encountered when loading 'https://domain.com/#/register': 'ALLOW-FROM domain.com' is not a recognized directive. The header will be ignored.
我尝试过的这些选项是:(也尝试使用带有 https:// 前缀的 FQDN)

  add_header X-Frame-Options "Allow-From domain.com"; 
  add_header X-Frame-Options "ALLOW-FROM domain.com"; 
  add_header X-Frame-Options "ALLOW-FROM: domain.com";
  add_header X-Frame-Options "Allow-From: domain.com";
  add_header X-Frame-Options ALLOW-FROM "domain.com";
  add_header X-Frame-Options ALLOW-FROM domain.com;

最佳答案

在 Chrome 和 Safari 中,您需要使用 内容安全策略

Content-Security-Policy: frame-ancestors domain.com

您可以在此网站上查看更多详细信息:

https://developer.mozilla.org/en-US/docs/Web/Security/CSP/CSP_policy_directives

关于nginx - 如何在 nginx 中正确设置 X-Frame-Options Allow-From,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30731290/

相关文章:

content-security-policy - 无法识别的内容安全策略指令 'script-src:'

NginX代理传递无限循环

Nginx 的 "reuseport"用于相同的 IP :PORT pair on different virtual hosts

nginx - Nginx不重定向到https docker端口

Opera 中的跨域 iframe 通信

cross-domain - 来自 XMLHttpRequest 的 CouchDB 跨域访问?

ssl - Typo3 多域与 ssl : TOO_MANY_REDIRECTS

webpack - Electron 加载资源失败

node.js - 使用来自拥有的域的 TLS 证书,并在 AWS Elastic Beanstalk 提供的 URL 上使用它

webforms - 自定义 Web 表单脚本生成