如何允许托管在 Amazon 上的站点嵌入到 iFrame 中?

How to Allow a Site Hosted with Amazon to Be Embedded in an iFrame?

我对 AWS 相当缺乏经验,所以这可能是理解站点结构或 Web 主机之间错综复杂的问题。

我曾经有一个网站托管在 HostMonster 上,并且能够允许从另一个域上的 iFrame 引用该网站。这是通过将 ALLOW-FROM 选项添加到 x-frame-options.

来实现的

该站点最近已移至 AWS。它使用 S3、EC2 和 Elastic Beanstalk。现在,当我尝试嵌入该网站时,出现此错误:

Refused to display 'http://example.com' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

显然我必须设置此选项,但我不清楚如何设置。

我找到了这个 forum asking for support for X-Frame-Options。来自 AWS 支持的响应确认 S3 当前不支持 X-Frame-Options。

这是否意味着我运气不好或者我只是找错了树?

我也查看了 aws CORS header setting docs 并尝试允许我嵌入的来源,甚至尝试允许来自 * 进行测试。

另外我发现了这个 GitHub for making S3 files public。我实施了他们在那里设置的策略和配置,但仍然出现相同的错误。

如果我好像遗漏了什么重要的东西,请问我。就像我说的那样,我对 Web 开发还很陌生,而且还在摸索中。

编辑:

正如所指出的,有趣的是 header 和 X-Frame-Options 被返回了。这是我直接加载页面时得到的完整响应。

Connection:keep-alive

Content-Type:text/html; charset=utf-8

Date:Sun, 19 Jun 2016 00:31:37 GMT

Server:Apache/2.4.16 (Amazon) OpenSSL/1.0.1k-fips mod_wsgi/3.5 Python/2.7.10

transfer-encoding:chunked

X-Frame-Options:SAMEORIGIN

您必须在 .ebextensions 中包含 enable_mod_deflate.conf 文件,设置 "Header always unset X-Frame-Options":

enable_mod_deflate.conf

# mod_deflate configuration
<IfModule mod_deflate.c>
  <IfModule mod_headers.c>
   # Make surei proxies don't deliver the wrong content
   Header always unset X-Frame-Options  
  </IfModule>
</IfModule>