# Install Discourse on a residential internet with Cloudflare Tunnel

**URL:** https://meta.discourse.org/t/install-discourse-on-a-residential-internet-with-cloudflare-tunnel/211297
**Category:** Sysadmins
**Tags:** arm, how-to, raspberry-pi, install
**Created:** [December 7, 2021, 2:02pm UTC](https://meta.discourse.org/t/install-discourse-on-a-residential-internet-with-cloudflare-tunnel/211297 "2021-12-07T14:02:07Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [December 7, 2021, 2:02pm UTC](https://meta.discourse.org/t/install-discourse-on-a-residential-internet-with-cloudflare-tunnel/211297/1 "2021-12-07T14:02:07Z")

</div>

Since [Discourse now has support for running on a Raspberry Pi](https://blog.discourse.org/2021/12/2021-12-07-discourse-on-a-raspberry-pi/), running a small instance in your home lab will become a common use case. However, many residential ISPs block incoming traffic to the ports 80/443 that Discourse need.

For our demo site at [https://discourse-on-a-pi.falco.dev/](https://discourse-on-a-pi.falco.dev/) we used [Cloudflare Tunnel](https://blog.cloudflare.com/tunnel-for-everyone/) to work around this, and you can do it too!

### Setup your tunnel

First, follow the following guide:

> **[Cloudflare Tunnel](https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/)**
>
> How Cloudflare Tunnel works in Zero Trust networking.

The only change you need is changing the URL from `url: http://localhost:8000` to `url: http://localhost:80`. Leave the tunnel running the background already.

### Disable Rocket Loader

You must disable Cloudfalre Rocket Loader for Discourse to work properly.

[https://community.cloudflare.com/t/how-can-i-remove-the-rocket-loader-script-from-the-header-tag-on-my-website/4229/2](https://community.cloudflare.com/t/how-can-i-remove-the-rocket-loader-script-from-the-header-tag-on-my-website/4229/2)

### Install Discourse

Follow [How to install Discourse in production](https://meta.discourse.org/t/how-to-install-discourse-in-production/142537), but hit CTRL+C after it creates the the app.yml file gives you a 5 seconds count-down.

Now edit the file first few lines so it looks like this:

```yaml
templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/cloudflare.template.yml"
# - "templates/web.ratelimited.template.yml"
## Uncomment these two lines if you wish to add Lets Encrypt (https)
# - "templates/web.ssl.template.yml"
# - "templates/web.letsencrypt.ssl.template.yml"

```

and add the following line under the `env:` section:

```yaml
DISCOURSE_FORCE_HTTPS: true

```

And then run `./launcher rebuild app`.

While you are waiting, install a page rule to always redirect to HTTPS like this:

 ![image](https://global.discourse-cdn.com/meta/original/4X/f/0/1/f01367ac5b19d9db3c7fa69de2afaa7c6d4638c3.png)

In a few minutes your new Discourse instance will be available on the domain you used in the tunnel/discourse configuration 🎉.

---

<div class="post-metadata">

### Author: ![tachibanalolo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tachibanalolo/32/233762_2.png) [@tachibanalolo](https://meta.discourse.org/u/tachibanalolo)
#### Post date: [December 7, 2021, 5:39pm UTC](https://meta.discourse.org/t/install-discourse-on-a-residential-internet-with-cloudflare-tunnel/211297/2 "2021-12-07T17:39:02Z")

</div>

I think it’s better that mention about port. If user decide to use argo tunnel, then they need to setup their port the same as tunnel settings. For example:

-80:80  
#-443:443

then they need to let the tunnel listen  
[http://localhost:80](http://localhost:80)

What I use is use unix socket to connect them.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [December 7, 2021, 6:02pm UTC](https://meta.discourse.org/t/install-discourse-on-a-residential-internet-with-cloudflare-tunnel/211297/3 "2021-12-07T18:02:06Z")

</div>

> [@tachibanalolo](#):
>
> then they need to let the tunnel listen  
> [http://localhost:80](http://localhost:80)

Isn’t that what I mention here:

> [@Falco](#):
>
> The only change you need is changing the URL from `url: http://localhost:8000` to `url: http://localhost:80` .

?

---

<div class="post-metadata">

### Author: ![Stigin](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@Stigin](https://meta.discourse.org/u/Stigin)
#### Post date: [December 22, 2021, 7:48am UTC](https://meta.discourse.org/t/install-discourse-on-a-residential-internet-with-cloudflare-tunnel/211297/4 "2021-12-22T07:48:15Z")

</div>

Hi Rafael,

Thanks for the tutorial.

I’ve followed everything as per your guide above and everything works fine however;

Upon clicking on the link in the email to activate my account I get flown back to the correct webpage with an activation button, however this button doesn’t work. I’ve looked up guidance on this forum and it looks like a domain to ip issue?

I have confirmed force\_https is set to true in the config.

Any thoughts / did you run into this issue (Screenshot attached) of the button that doesn’t do anything?

 ![SCR-20211222-q2s](https://global.discourse-cdn.com/meta/original/3X/d/7/d719796eadfac28cd1613622d8e834e4e89d0595.png)

---

<div class="post-metadata">

### Author: ![Stigin](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@Stigin](https://meta.discourse.org/u/Stigin)
#### Post date: [December 22, 2021, 8:34am UTC](https://meta.discourse.org/t/install-discourse-on-a-residential-internet-with-cloudflare-tunnel/211297/5 "2021-12-22T08:34:02Z")

</div>

Alright so I managed to fix this.

Just ensure rocket loader is disabled 😉

Cheers!

---

<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: [January 24, 2022, 4:50am UTC](https://meta.discourse.org/t/install-discourse-on-a-residential-internet-with-cloudflare-tunnel/211297/6 "2022-01-24T04:50:00Z")

</div>

Finally, installed Discourse on Raspberry Pi. But i have problems with Cloudflare Tunnels.

I can’t access to Discourse site with domain, something strange in the config.yml configuration?

```plaintext
url: http://localhost:80
tunnel: 371dd57c- ************
credentials-file: /home/pi/.cloudflared/371dd57c- *********.json

```

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [January 24, 2022, 4:53am UTC](https://meta.discourse.org/t/install-discourse-on-a-residential-internet-with-cloudflare-tunnel/211297/7 "2022-01-24T04:53:51Z")

</div>

What is the tunnel command output? It should be explicit about any mistakes you made on the configuration.

---

<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: [January 24, 2022, 4:57am UTC](https://meta.discourse.org/t/install-discourse-on-a-residential-internet-with-cloudflare-tunnel/211297/8 "2022-01-24T04:57:39Z")

</div>

cloudflared tunnel info output:

```plaintext
cloudflared tunnel info ******
2022-01-24T04:55:47Z INF Cannot determine default origin certificate path. No file cert.pem in [~/.cloudflared ~/.cloudflare-warp ~/cloudflare-warp /etc/cloudflared /usr/local/etc/cloudflared] originCertPath=
2022-01-24T04:55:47Z ERR You need to specify the origin certificate path with --origincert option, or set TUNNEL_ORIGIN_CERT environment variable. See https://developers.cloudflare.com/argo-tunnel/reference/arguments/ for more information. originCertPath=
error parsing tunnel ID: Error locating origin cert: client didn't specify origincert path when running from terminal

```

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [January 24, 2022, 5:00am UTC](https://meta.discourse.org/t/install-discourse-on-a-residential-internet-with-cloudflare-tunnel/211297/9 "2022-01-24T05:00:40Z")

</div>

Looks like you misplaced the certificate file? If you are running as root, the file should be under

`/root/.cloudflared/`

and not where you put it as

> [@bekircem](#):
>
> `credentials-file: /home/pi/.cloudflared/`

---

<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: [January 24, 2022, 5:11am UTC](https://meta.discourse.org/t/install-discourse-on-a-residential-internet-with-cloudflare-tunnel/211297/10 "2022-01-24T05:11:22Z")

</div>

> [@bekircem](#):
>
> /home/pi/.cloudflared/

I have already cert.pem file.

 ![image](https://global.discourse-cdn.com/meta/original/3X/4/0/4016341ad89d1ec5e330b3c6826f537437d765d5.png)

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [January 24, 2022, 5:33am UTC](https://meta.discourse.org/t/install-discourse-on-a-residential-internet-with-cloudflare-tunnel/211297/11 "2022-01-24T05:33:42Z")

</div>

And are you trying to start the tunnel as the `pi` user or as root?

---

<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: [January 24, 2022, 9:08am UTC](https://meta.discourse.org/t/install-discourse-on-a-residential-internet-with-cloudflare-tunnel/211297/12 "2022-01-24T09:08:28Z")

</div>

I am using this command as pi user

`cloudflared tunnel run <UUID or NAME>`

 ![image](https://global.discourse-cdn.com/meta/original/3X/4/8/48c88de9de5adc126384d5294c217882fbc44c93.png)

---

<div class="post-metadata">

### Author: ![Stigin](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@Stigin](https://meta.discourse.org/u/Stigin)
#### Post date: [January 24, 2022, 10:40am UTC](https://meta.discourse.org/t/install-discourse-on-a-residential-internet-with-cloudflare-tunnel/211297/13 "2022-01-24T10:40:03Z")

</div>

Hi @bekircem,

It looks like your Cloudflared has been able to initiate a connection to Cloudflare’s edge.

Have you enabled the Routing with a CNAME to your Argo Tunnel ID on Cloudflare?

> **[DNS records](https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/routing-to-tunnel/dns/)**
>
> DNS records in Zero Trust networking.

Cheers,

Alex.

---

<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: [January 24, 2022, 10:53am UTC](https://meta.discourse.org/t/install-discourse-on-a-residential-internet-with-cloudflare-tunnel/211297/14 "2022-01-24T10:53:24Z")

</div>

Hi @Stigin, thank you for the reply.

Yes, i am enabled routing from the command line

 ![image](https://global.discourse-cdn.com/meta/original/3X/4/3/434982a6f96d8cf9b0cde0d458416d28f5358fe0.jpeg)

---

<div class="post-metadata">

### Author: ![Stigin](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@Stigin](https://meta.discourse.org/u/Stigin)
#### Post date: [January 24, 2022, 11:00am UTC](https://meta.discourse.org/t/install-discourse-on-a-residential-internet-with-cloudflare-tunnel/211297/15 "2022-01-24T11:00:04Z")

</div>

Interesting one @bekircem - Hmm!!

What is the current error you’re getting when browsing to your website address? Is it just a generic Cloudflare Argo Tunnel error page?

Could you please show us your running containers by running the command: _docker ps_ and show us your current running tunnels with _cloudflared tunnel list_ || Make sure you blur out your argo route / any non-relevant containers! 😉

Alex.

---

<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: [January 24, 2022, 3:55pm UTC](https://meta.discourse.org/t/install-discourse-on-a-residential-internet-with-cloudflare-tunnel/211297/16 "2022-01-24T15:55:58Z")

</div>

> What is the current error you’re getting when browsing to your website address? Is it just a generic Cloudflare Argo Tunnel error page?

No there is no Cloudflare Argo Tunnel error page.

`ERR_NAME_NOT_RESOLVED`

**docker ps**

```plaintext
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f1bde9b70f55 local_discourse/app "/sbin/boot" 11 hours ago Up 11 hours 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp app

```

When use this command as a root user **cloudflared tunnel list**

```plaintext
2022-01-24T15:55:03Z INF Cannot determine default origin certificate path. No file cert.pem in [~/.cloudflared ~/.cloudflare-warp ~/cloudflare-warp /etc/cloudflared /usr/local/etc/cloudflared] originCertPath=
2022-01-24T15:55:03Z ERR You need to specify the origin certificate path with --origincert option, or set TUNNEL_ORIGIN_CERT environment variable. See https://developers.cloudflare.com/argo-tunnel/reference/arguments/ for more information. originCertPath=
Error locating origin cert: client didn't specify origincert path when running from terminal

```

When use this command as a pi user **cloudflared tunnel list**

```plaintext
You can obtain more detailed information for each tunnel with `cloudflared tunnel info <name/uuid>`
ID NAME CREATED CONNECTIONS
371dd57c- ****************ze**** 2022-01-24T03:35:19Z

```

It is normal?

We need to use a subdomain for DISCOURSE\_HOSTNAME in the config.yml file, right?

Update: I am uninstalled Cloudflared and reinstalled with root user and it works now. I still don’t understand where exactly I went wrong in my previous attempt.

---

<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: [January 25, 2022, 2:31am UTC](https://meta.discourse.org/t/install-discourse-on-a-residential-internet-with-cloudflare-tunnel/211297/17 "2022-01-25T02:31:38Z")

</div>

Somehow I finally ran the site on Raspberry and it’s live.

I don’t really understand how. I am removed Cloudflared and re-install it with root user. And it works…

I have two questions,

1- It seems my SSL certificate not work correctly so I can’t login to my admin account on Discourse. (It appears to be running in incognito tab. Maybe it’s something about cache.) Are you using full or full(strict)?

 ![image](https://global.discourse-cdn.com/meta/original/4X/a/0/5/a05102abedc28be4f5366cdc67baf85980b330b7.jpeg)

2- I have questions about running cloudflared as a service. [https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/run-tunnel/run-as-service](https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/run-tunnel/run-as-service)

I ran tunnel with `cloudflared tunnel run <UUID or NAME>` command. But when i close the iterm windows will it stop working?

 ![image](https://global.discourse-cdn.com/meta/original/4X/3/4/f/34fa1c61eed939b1447af80509238f1eff9ad106.png)

> If you have already logged in and have a configuration file in `~/.cloudflared/` , these will be copied to `/etc/cloudflared/` .
> 
> If you do not have a configuration file, you will need to create a config.yml file with fields listed above. You can pass a custom file by running `cloudflared --config CONFIG-FILE service install` .

I checked, i don’t have configuration file in `/etc/cloudflared/`. In this case, what should I do to run this service automatically?

Thank you.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [January 25, 2022, 2:45am UTC](https://meta.discourse.org/t/install-discourse-on-a-residential-internet-with-cloudflare-tunnel/211297/18 "2022-01-25T02:45:20Z")

</div>

Questions that are more specific about the Cloudflare tunnel service may receive better answers at [https://community.cloudflare.com/tag/cloudflaretunnel](https://community.cloudflare.com/tag/cloudflaretunnel)

---

<div class="post-metadata">

### Author: ![Stigin](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@Stigin](https://meta.discourse.org/u/Stigin)
#### Post date: [January 25, 2022, 3:00am UTC](https://meta.discourse.org/t/install-discourse-on-a-residential-internet-with-cloudflare-tunnel/211297/19 "2022-01-25T03:00:47Z")

</div>

Hey @bekircem,

I think reinstalling it would of fixed the issue of cloudflared not finding the certificate…

With regards to running Cloudflare as a service - the configuration file you created when running the service manually will need to be moved to /etc/cloudflared.

I’m unsure about linking personal sites here so please let me know if I need to remove this but I’ve covered this under my one of my blogs under the section called: ‘[Setup and Run Cloudflared as a Service](https://alexgallacher.com/how-to-configure-cloudflare-tunnels-for-a-secure-ghost-blog/)’

Let us know how you get on!

Alex.

---

<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: [January 25, 2022, 3:51am UTC](https://meta.discourse.org/t/install-discourse-on-a-residential-internet-with-cloudflare-tunnel/211297/20 "2022-01-25T03:51:07Z")

</div>

Thank you for the reply.

Great blog post, thanks for sharing.

### Run Cloudflared as a Service

`sudo cloudflared service install`

config.yml file automatically copied to /etc/cloudflared/.

`sudo systemctl start cloudflared`

`sudo systemctl enable cloudflared`

And it’s working great. I haven’t tried rebooting yet but I hope it will work.

[Next page](https://meta.discourse.org/t/install-discourse-on-a-residential-internet-with-cloudflare-tunnel/211297.md?page=2)
