# Support embedding Discourse in an iframe

**URL:** https://meta.discourse.org/t/support-embedding-discourse-in-an-iframe/50405
**Category:** Feature
**Tags:** embedding
**Created:** [2016年九月20日 18:46 UTC](https://meta.discourse.org/t/support-embedding-discourse-in-an-iframe/50405 "2016-09-20T18:46:09Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![aarongray](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aarongray/32/121516_2.png) [@aarongray](https://meta.discourse.org/u/aarongray)
#### Post date: [2016年九月20日 18:46 UTC](https://meta.discourse.org/t/support-embedding-discourse-in-an-iframe/50405/1 "2016-09-20T18:46:09Z")

</div>

Howdy!

I’m developing a web app, and I’d love to use Discourse as my forums / community discussion platform. One of my main requirements though is that the forum should be able to be opened in an iframe docked to the side of my UI, so that users can browse tutorials, talk to other people, or contact support all within the comfort of the app itself. This is a huge win for UX, and because Discourse is responsive and mobile friendly, a small iframe should work well for this use case. It seems like this would be an awesome feature for Discourse that many people might use.

I saw this old discussion about [this topic](https://meta.discourse.org/t/discourse-not-shown-in-iframe/26970/5), which includes [one proposed solution](https://meta.discourse.org/t/discourse-not-shown-in-iframe/26970/5).

So I wanted to ask the maintainers and folks here, is this a feature that you would be open to a PR for? Would you consider adding this feature? Are there any issues with that solution that was proposed that would need to be dealt with?

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [2016年九月20日 19:09 UTC](https://meta.discourse.org/t/support-embedding-discourse-in-an-iframe/50405/2 "2016-09-20T19:09:31Z")

</div>

> [@aarongray](#):
>
> Are there any issues

The main issue I see is that of opening up possible Security problems. eg.

[Cross Frame Scripting](https://www.owasp.org/index.php/Cross_Frame_Scripting)

---

<div class="post-metadata">

### Author: ![aarongray](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aarongray/32/121516_2.png) [@aarongray](https://meta.discourse.org/u/aarongray)
#### Post date: [2016年九月20日 19:18 UTC](https://meta.discourse.org/t/support-embedding-discourse-in-an-iframe/50405/3 "2016-09-20T19:18:59Z")

</div>

Interesting, thanks for pointing that out.

If Cross Frame Scripting was a concern, could we allow people to specify a trusted domain(s)?

For example, the `ALLOW-FROM` URI in the `X-FRAME-OPTIONS` header. See [here](https://www.owasp.org/index.php/Clickjacking_Defense_Cheat_Sheet#Defending_with_X-Frame-Options_Response_Headers).

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [2016年九月20日 19:27 UTC](https://meta.discourse.org/t/support-embedding-discourse-in-an-iframe/50405/4 "2016-09-20T19:27:59Z")

</div>

> [@aarongray](#):
>
> can you edit it?

![](https://global.discourse-cdn.com/meta/original/3X/e/a/ea81a0eed36f328c0f88f877bdc03b4db47a73b0.gif) pasted the wrong URL - link fixed

> [@aarongray](#):
>
> could we allow people to specify a trusted domain(s)?

Yes, sending headers should take care of most if not all security risks.  
(I say most because I don’t know if some older browsers might not use the headers)

---

<div class="post-metadata">

### Author: ![aarongray](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aarongray/32/121516_2.png) [@aarongray](https://meta.discourse.org/u/aarongray)
#### Post date: [2016年九月20日 19:29 UTC](https://meta.discourse.org/t/support-embedding-discourse-in-an-iframe/50405/5 "2016-09-20T19:29:54Z")

</div>

Okie dokie 👍

---

<div class="post-metadata">

### Author: ![tophee](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tophee/32/73406_2.png) [@tophee](https://meta.discourse.org/u/tophee)
#### Post date: [2017年二月21日 12:20 UTC](https://meta.discourse.org/t/support-embedding-discourse-in-an-iframe/50405/6 "2017-02-21T12:20:15Z")

</div>

Not being a developer, this thread leaves me puzzled about what the conclusion is regarding embedding discourse in an IFRAME. When you say:

> [@Mittineague](#):
>
> aarongray:  
> could we allow people to specify a trusted domain(s)?
> 
> Yes, sending headers should take care of most if not all security risks. (I say most because I don’t know if some older browsers might not use the headers)

This sounds to me like: problem solved, especially since - in my case - everything would not only be happening under the same domain but even on the same server. But my understaning is also that this is nevertheless [not supported](https://meta.discourse.org/t/discourse-not-shown-in-iframe/26970/5) and therefore not recommended for people like me. But why? If trusted domains can be specified?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2017年二月21日 12:55 UTC](https://meta.discourse.org/t/support-embedding-discourse-in-an-iframe/50405/7 "2017-02-21T12:55:54Z")

</div>

Because it’s an extremely fragile configuration. Discourse expects to control the browser tightly as a JavaScript app. This is not a static 1996 era web page to be slapped in an `<iframe>` willy-nilly, it’s _far_ more complex.

---

<div class="post-metadata">

### Author: ![LoganKilpatrick](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/logankilpatrick/32/208036_2.png) [@LoganKilpatrick](https://meta.discourse.org/u/LoganKilpatrick)
#### Post date: [2021年二月6日 21:32 UTC](https://meta.discourse.org/t/support-embedding-discourse-in-an-iframe/50405/8 "2021-02-06T21:32:32Z")

</div>

@codinghorror 关于此事有任何更新吗？如果能将日历嵌入我们的网站，使风格统一，那就太好了。

编辑：我只是希望能够在我们的网站上嵌入这个页面：[Julia Programming Language](https://discourse.julialang.org/upcoming-events)

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2021年二月7日 02:46 UTC](https://meta.discourse.org/t/support-embedding-discourse-in-an-iframe/50405/9 "2021-02-07T02:46:37Z")

</div>

也许有一个隐藏设置可以关闭 no-iframe 指令，我暂时想不起来了，但我们加入它是出于充分的理由。

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2021年二月7日 03:04 UTC](https://meta.discourse.org/t/support-embedding-discourse-in-an-iframe/50405/10 "2021-02-07T03:04:50Z")

</div>

我觉得这更像是对插件的功能请求，嵌入内容应与整个页面有所区别。

Cc @j.jaffeux

---

<div class="post-metadata">

### Author: ![bekircem](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bekircem/32/44582_2.png) [@bekircem](https://meta.discourse.org/u/bekircem)
#### Post date: [2022年五月14日 11:59 UTC](https://meta.discourse.org/t/support-embedding-discourse-in-an-iframe/50405/12 "2022-05-14T11:59:18Z")

</div>

> **[GitHub - BeXcellent/discourse-allowiframe: Changes X-Frame-Options to allow iframe embedding.](https://github.com/BeXcellent/discourse-allowiframe)**
>
> Changes X-Frame-Options to allow iframe embedding.

这是一个简单的插件。但是，它不起作用。由于它是在 6 年前更新的，能否通过简单的更改使其正常工作？

```plaintext
# name: 允许 iFrame 嵌入
# about: 更改 X-Frame-Options 以便嵌入站点
# version: 1
# authors: bex-team, riking,

Rails.application.config.action_dispatch.default_headers.merge!({'X-Frame-Options' => 'ALLOWALL'})

```

---

<div class="post-metadata">

### Author: ![denvergeeks](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/denvergeeks/32/327671_2.png) [@denvergeeks](https://meta.discourse.org/u/denvergeeks)
#### Post date: [2023年六月1日 00:04 UTC](https://meta.discourse.org/t/support-embedding-discourse-in-an-iframe/50405/13 "2023-06-01T00:04:04Z")

</div>

如果想不受限制地将 Discourse 嵌入 iframe 中，则需要进行两项设置：

1. 在“设置”中取消选中 CSP 限制  

2. 启用隐藏的站点设置 `allow_embedding_site_in_an_iframe`

```plaintext
cd /var/discourse
./launcher enter app
rails c
SiteSetting.allow_embedding_site_in_an_iframe=true
exit
exit

```

---

<div class="post-metadata">

### Author: ![Yahia\_Kala](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yahia_kala/32/345887_2.png) [@Yahia\_Kala](https://meta.discourse.org/u/Yahia_Kala)
#### Post date: [2024年三月18日 00:36 UTC](https://meta.discourse.org/t/support-embedding-discourse-in-an-iframe/50405/14 "2024-03-18T00:36:17Z")

</div>

@denvergeeks 我试过了，但我的论坛仍然无法嵌入 iframe。

---

<div class="post-metadata">

### Author: ![denvergeeks](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/denvergeeks/32/327671_2.png) [@denvergeeks](https://meta.discourse.org/u/denvergeeks)
#### Post date: [2024年三月18日 01:29 UTC](https://meta.discourse.org/t/support-embedding-discourse-in-an-iframe/50405/15 "2024-03-18T01:29:42Z")

</div>

您要嵌入的网站的网址是什么？

---

<div class="post-metadata">

### Author: ![Yahia\_Kala](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yahia_kala/32/345887_2.png) [@Yahia\_Kala](https://meta.discourse.org/u/Yahia_Kala)
#### Post date: [2024年三月18日 02:28 UTC](https://meta.discourse.org/t/support-embedding-discourse-in-an-iframe/50405/16 "2024-03-18T02:28:19Z")

</div>

forum.dreambyte.ai

---

<div class="post-metadata">

### Author: ![denvergeeks](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/denvergeeks/32/327671_2.png) [@denvergeeks](https://meta.discourse.org/u/denvergeeks)
#### Post date: [2024年四月19日 04:00 UTC](https://meta.discourse.org/t/support-embedding-discourse-in-an-iframe/50405/17 "2024-04-19T04:00:20Z")

</div>

您发布的网址我根本无法加载……如果您能让它加载，我就可以在我的网站上进行测试，我的网站支持 iframe 嵌入。

 ![Screenshot 2024-04-18 215828](https://global.discourse-cdn.com/meta/original/4X/f/d/b/fdbe1b90af3617d2d3fc29fdef0a1cd2aff25dc7.png)

---

<div class="post-metadata">

### Author: ![yasnikoy](https://avatars.discourse-cdn.com/v4/letter/y/b19c9b/32.png) [@yasnikoy](https://meta.discourse.org/u/yasnikoy)
#### Post date: [2025年六月13日 13:44 UTC](https://meta.discourse.org/t/support-embedding-discourse-in-an-iframe/50405/18 "2025-06-13T13:44:56Z")

</div>

如果我能在其他网站上嵌入 Discourse 日历，对我来说会非常有帮助。这方面有什么进展吗？
