# Discourse not shown in iframe

**URL:** https://meta.discourse.org/t/discourse-not-shown-in-iframe/26970
**Category:** Support
**Tags:** unsupported-install
**Created:** [March 30, 2015, 1:45am UTC](https://meta.discourse.org/t/discourse-not-shown-in-iframe/26970 "2015-03-30T01:45:10Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![dreadkopp](https://avatars.discourse-cdn.com/v4/letter/d/67e7ee/32.png) [@dreadkopp](https://meta.discourse.org/u/dreadkopp)
#### Post date: [March 30, 2015, 1:45am UTC](https://meta.discourse.org/t/discourse-not-shown-in-iframe/26970/1 "2015-03-30T01:45:10Z")

</div>

Aloha Communtiy, i am trying to put discourse in an iframe since i don’t have free wildcards at my dyndny hoster.

I run my main apache server at port 80 and the docker containing discourse redirects to port 82.

the page i am talking about is here: [http://archy.no-ip.org/forum/](http://archy.no-ip.org/forum/)

instead of the discourse page at [http://archy.no-ip.org:81](http://archy.no-ip.org:81) it just shows the blank container.

i first thought that it might be a problem with iframe to shown pages which don’t use port 80 or 443 but since another test shows that my plone-environment at port 81 ([http://archy.no-ip.org/iframe-test-different-port/](http://archy.no-ip.org/iframe-test-different-port/)) is shown correctly that cannot be it.

Any ideas what’s wrong?

thanks and greetings

---

<div class="post-metadata">

### Author: ![jesselperry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jesselperry/32/119501_2.png) [@jesselperry](https://meta.discourse.org/u/jesselperry)
#### Post date: [March 30, 2015, 1:53am UTC](https://meta.discourse.org/t/discourse-not-shown-in-iframe/26970/2 "2015-03-30T01:53:16Z")

</div>

I wouldn’t plan on it happening.

[https://meta.discourse.org/t/loading-stuck-inside-an-iframe/20467/6](https://meta.discourse.org/t/loading-stuck-inside-an-iframe/20467/6)

---

<div class="post-metadata">

### Author: ![dreadkopp](https://avatars.discourse-cdn.com/v4/letter/d/67e7ee/32.png) [@dreadkopp](https://meta.discourse.org/u/dreadkopp)
#### Post date: [March 30, 2015, 3:02am UTC](https://meta.discourse.org/t/discourse-not-shown-in-iframe/26970/3 "2015-03-30T03:02:39Z")

</div>

But why isn’t it working? can there be done anything else to integrate it into the website?

---

<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: [March 30, 2015, 3:09am UTC](https://meta.discourse.org/t/discourse-not-shown-in-iframe/26970/4 "2015-03-30T03:09:16Z")

</div>

We do not support running in an iframe.

---

<div class="post-metadata">

### Author: ![elberet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elberet/32/122404_2.png) [@elberet](https://meta.discourse.org/u/elberet)
#### Post date: [March 30, 2015, 4:05am UTC](https://meta.discourse.org/t/discourse-not-shown-in-iframe/26970/5 "2015-03-30T04:05:55Z")

</div>

Discourse (actually Rails) sends a `X-Frame-Options` header that tells browsers that the site does not wish to be embedded in an iframe, hence all modern browsers will simply render a white square. You can see this in e.g. Chrome’s dev console which says

```
Refused to display 'http://archy.no-ip.org:82/' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

```

The only way to “fix” this is to hack Discourse yourself: move the `EmbedController`’s `before_filter` and `ensure_embeddable` method into the main `ApplicationController` and set the `embeddable host` site setting. But, while it _can_ be done, you’ll be on _extremely_ unsupported terrain…

---

<div class="post-metadata">

### Author: ![dreadkopp](https://avatars.discourse-cdn.com/v4/letter/d/67e7ee/32.png) [@dreadkopp](https://meta.discourse.org/u/dreadkopp)
#### Post date: [March 30, 2015, 2:35pm UTC](https://meta.discourse.org/t/discourse-not-shown-in-iframe/26970/6 "2015-03-30T14:35:04Z")

</div>

thanks a lot! i thought it would be pretty to have it in an iframe.

will look if i can dig in the code to remove this X-Frame-Options header.

since then i will just use a link.

Many thanks for your reply!

---

<div class="post-metadata">

### Author: ![xiasummer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xiasummer/32/82790_2.png) [@xiasummer](https://meta.discourse.org/u/xiasummer)
#### Post date: [September 18, 2016, 9:55am UTC](https://meta.discourse.org/t/discourse-not-shown-in-iframe/26970/7 "2016-09-18T09:55:30Z")

</div>

I don’t think this is a good answer, we need to know how to support. You can say not supporting now, and the probability solution is …

---

<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: [September 18, 2016, 5:36pm UTC](https://meta.discourse.org/t/discourse-not-shown-in-iframe/26970/8 "2016-09-18T17:36:33Z")

</div>

That post was made before the probability [sic possible] solution was provided in the next post made by elberet

> [@Discourse not shown in iframe](https://meta.discourse.org/t/discourse-not-shown-in-iframe/26970/5):
>
> Discourse (actually Rails) sends a X-Frame-Options header that tells browsers that the site does not wish to be embedded in an iframe, hence all modern browsers will simply render a white square. You can see this in e.g. Chrome’s dev console which says Refused to display 'http://archy.no-ip.org:82/' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'. The only way to “fix” this is to hack Discourse yourself: move the EmbedController’s before\_filter and ensure\_embeddable method into the…

---

<div class="post-metadata">

### Author: ![dubeydeepak](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dubeydeepak/32/70085_2.png) [@dubeydeepak](https://meta.discourse.org/u/dubeydeepak)
#### Post date: [March 31, 2017, 8:23am UTC](https://meta.discourse.org/t/discourse-not-shown-in-iframe/26970/9 "2017-03-31T08:23:42Z")

</div>

> [@elberet](#):
>
> in a frame because it set ‘X-Frame-Options’ to 'SAMEORI

Just need to add below points inside env Tag, & it will help in fixing issue **Xframe option with sameorigin**. works for me. 😀

**env:**  
UNICORN\_WORKERS: 4  
DISCOURSE\_ENABLE\_CORS: true\*\*  
DISCOURSE\_CORS\_ORIGIN: ‘\*’

---

<div class="post-metadata">

### Author: ![Kai\_Middleton](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kai_middleton/32/78159_2.png) [@Kai\_Middleton](https://meta.discourse.org/u/Kai_Middleton)
#### Post date: [September 6, 2017, 4:15am UTC](https://meta.discourse.org/t/discourse-not-shown-in-iframe/26970/10 "2017-09-06T04:15:33Z")

</div>

I’m able to load Discourse in an iframe … on Firefox. But not Chrome (or Safari). In Chrome I have the following problem: _Nothing_ is clickable! If I open the inspector and drill into the source it will highlight various elements (e.g. rows), but neither right clicks nor left clicks on any content of iframe have an effect. Any suggestions?

---

<div class="post-metadata">

### Author: ![Julian\_Somoza](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@Julian\_Somoza](https://meta.discourse.org/u/Julian_Somoza)
#### Post date: [August 16, 2018, 6:41pm UTC](https://meta.discourse.org/t/discourse-not-shown-in-iframe/26970/11 "2018-08-16T18:41:42Z")

</div>

> [@dubeydeepak](#):
>
> ll help in fixing issue **Xframe option with sameorigin**. w

That not change the X-Frame-Options header flag…

---

<div class="post-metadata">

### Author: ![Julian\_Somoza](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@Julian\_Somoza](https://meta.discourse.org/u/Julian_Somoza)
#### Post date: [August 16, 2018, 6:48pm UTC](https://meta.discourse.org/t/discourse-not-shown-in-iframe/26970/12 "2018-08-16T18:48:45Z")

</div>

There is some checksum or something… because if I modify this file the app wont start…

---

<div class="post-metadata">

### Author: ![jack2](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@jack2](https://meta.discourse.org/u/jack2)
#### Post date: [August 16, 2018, 7:24pm UTC](https://meta.discourse.org/t/discourse-not-shown-in-iframe/26970/13 "2018-08-16T19:24:11Z")

</div>

A solution to run Discourse in an iframe is to create a plugin that contains the following code in `plugin.rb`:

```plaintext
# Changes X-Frame-Options so the site can be embedded in an iframe. See:
# https://github.com/BeXcellent/discourse-allowiframe/blob/master/plugin.rb
# https://github.com/TheBunyip/discourse-allow-same-origin/blob/master/plugin.rb
Rails.application.config.action_dispatch.default_headers.merge!({'X-Frame-Options' => 'ALLOWALL'})

```

---

<div class="post-metadata">

### Author: ![Julian\_Somoza](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@Julian\_Somoza](https://meta.discourse.org/u/Julian_Somoza)
#### Post date: [August 17, 2018, 1:46pm UTC](https://meta.discourse.org/t/discourse-not-shown-in-iframe/26970/14 "2018-08-17T13:46:49Z")

</div>

Thanks Jack! I was forked and uploaded a plugin on github in case of someone need it…

> <https://github.com/somoza/discourse-xorigin/blob/master/plugin.rb>

---

<div class="post-metadata">

### Author: ![Julian\_Somoza](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@Julian\_Somoza](https://meta.discourse.org/u/Julian_Somoza)
#### Post date: [August 21, 2018, 5:32pm UTC](https://meta.discourse.org/t/discourse-not-shown-in-iframe/26970/15 "2018-08-21T17:32:04Z")

</div>

There is a new challenge now, inside the iframe appear an “You were logged out.” modal… I’m researching for solve this…

 ![image](https://global.discourse-cdn.com/meta/original/3X/e/1/e19aab0b34682ec888d26f241d7a1460a4506d83.png)

---

<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: [August 21, 2018, 8:33pm UTC](https://meta.discourse.org/t/discourse-not-shown-in-iframe/26970/16 "2018-08-21T20:33:33Z")

</div>

We do say this is unsupported for a reason.

[https://media.giphy.com/media/xT1R9KJH2bXffKbjwc/giphy.mp4](https://media.giphy.com/media/xT1R9KJH2bXffKbjwc/giphy.mp4)

---

<div class="post-metadata">

### Author: ![Julian\_Somoza](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@Julian\_Somoza](https://meta.discourse.org/u/Julian_Somoza)
#### Post date: [August 22, 2018, 1:02pm UTC](https://meta.discourse.org/t/discourse-not-shown-in-iframe/26970/17 "2018-08-22T13:02:55Z")

</div>

And the reason is…?

---

<div class="post-metadata">

### Author: ![jack2](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@jack2](https://meta.discourse.org/u/jack2)
#### Post date: [August 22, 2018, 1:28pm UTC](https://meta.discourse.org/t/discourse-not-shown-in-iframe/26970/18 "2018-08-22T13:28:25Z")

</div>

@Julian_Somoza, the Discourse team promotes an opinionated way of using Discourse and will not support alternatives. Additionally, they always reminds people of that fact.

That being said, I’m not from the Discourse team, so I can discuss your issue 🙂 I use Discourse in an iframe for my project and never got the “You were logged out” modal.

---

<div class="post-metadata">

### Author: ![Julian\_Somoza](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@Julian\_Somoza](https://meta.discourse.org/u/Julian_Somoza)
#### Post date: [August 22, 2018, 1:51pm UTC](https://meta.discourse.org/t/discourse-not-shown-in-iframe/26970/19 "2018-08-22T13:51:08Z")

</div>

And you just overrided the X-Frame-Options header or you did something else? We use Zimbra and want to put the Discourse inside a Zimlet…

---

<div class="post-metadata">

### Author: ![jack2](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@jack2](https://meta.discourse.org/u/jack2)
#### Post date: [August 22, 2018, 2:08pm UTC](https://meta.discourse.org/t/discourse-not-shown-in-iframe/26970/20 "2018-08-22T14:08:09Z")

</div>

I overrided The `X-Frame-Options` header.  
I also set `same site cookies` do `Disabled` in the settings, but I don’t remember why and if it is required.

[Next page](https://meta.discourse.org/t/discourse-not-shown-in-iframe/26970.md?page=2)
