@cryptotaxi247 / netdata-1 / commits / 7247a5a3a

Doc about running a local dashboard through Cloudflare (community) (#16043)

Fotis Voutsas committed Sep 26, 2023 at 10:51 UTC 7247a5a3a7c8c470843de63dd6a7cde0826b4c59
1 file changed +113
docs/running-through-cf-tunnels.md new
+113
@@ -0,0 +1,113 @@
1 +# Running a Local Dashboard through Cloudflare Tunnels
2 +
3 +## Summary of tasks
4 +
5 +- Make a `netdata-web` HTTP tunnel on the parent node, so the web interface can be viewed publicly
6 +- Make a `netdata-tcp` tcp tunnel on the parent node, so it can receive tcp streams from child nodes
7 +- Provide access to the `netdata-tcp` tunnel on the child nodes, so you can send the tcp stream to the parent node
8 +- Make sure the parent node uses port `19999` for both web and tcp streams
9 +- Make sure that the child nodes have `mode = none` in the `[web]` section of the `netdata.conf` file, and `destination = tcp:127.0.0.1:19999` in the `[stream]` section of the `stream.conf` file
10 +
11 +## Detailed instructions with commands and service files
12 +
13 +- Install the `cloudflared` package on all your Netdata nodes, follow the repository instructions [here](https://pkg.cloudflare.com/index.html)
14 +
15 +- Login to cloudflare with `sudo cloudflared login` on all your Netdata nodes
16 +
17 +### Parent node: public web interface and receiving stats from Child nodes
18 +
19 +- Create the HTTP tunnel
20 + `sudo cloudflared tunnel create netdata-web`
21 +- Start routing traffic
22 + `sudo cloudflared tunnel route dns netdata-web netdata-web.my.domain`
23 +- Create a service by making a file called `/etc/systemd/system/cf-tun-netdata-web.service` and input:
24 +
25 +```ini
26 +[Unit]
27 +Description=cloudflare tunnel netdata-web
28 +After=network-online.target
29 +
30 +[Service]
31 +Type=simple
32 +User=root
33 +Group=root
34 +ExecStart=/usr/bin/cloudflared --no-autoupdate tunnel run --url http://localhost:19999 netdata-web
35 +Restart=on-failure
36 +TimeoutStartSec=0
37 +RestartSec=5s
38 +
39 +[Install]
40 +WantedBy=multi-user.target
41 +```
42 +
43 +- Create the TCP tunnel
44 + `sudo cloudflared tunnel create netdata-tcp`
45 +- Start routing traffic
46 + `sudo cloudflared tunnel route dns netdata-tcp netdata-tcp.my.domain`
47 +- Create a service by making a file called `/etc/systemd/system/cf-tun-netdata-tcp.service` and input:
48 +
49 +```ini
50 +[Unit]
51 +Description=cloudflare tunnel netdata-tcp
52 +After=network-online.target
53 +
54 +[Service]
55 +Type=simple
56 +User=root
57 +Group=root
58 +ExecStart=/usr/bin/cloudflared --no-autoupdate tunnel run --url tcp://localhost:19999 netdata-tcp
59 +Restart=on-failure
60 +TimeoutStartSec=0
61 +RestartSec=5s
62 +
63 +[Install]
64 +WantedBy=multi-user.target
65 +```
66 +
67 +### Child nodes: send stats to the Parent node
68 +
69 +- Create a service by making a file called `/etc/systemd/system/cf-acs-netdata-tcp.service` and input:
70 +
71 +```ini
72 +[Unit]
73 +Description=cloudflare access netdata-tcp
74 +After=network-online.target
75 +
76 +[Service]
77 +Type=simple
78 +User=root
79 +Group=root
80 +ExecStart=/usr/bin/cloudflared --no-autoupdate access tcp --url localhost:19999 --tunnel-host netdata-tcp.my.domain
81 +Restart=on-failure
82 +TimeoutStartSec=0
83 +RestartSec=5s
84 +
85 +[Install]
86 +WantedBy=multi-user.target
87 +```
88 +
89 +You can edit the configuration file using the `edit-config` script from the Netdata [config directory](https://github.com/netdata/netdata/blob/master/docs/configure/nodes.md#the-netdata-config-directory).
90 +
91 +- Edit `netdata.conf` and input:
92 +
93 +```ini
94 +[web]
95 + mode = none
96 +```
97 +
98 +- Edit `stream.conf` and input:
99 +
100 +```ini
101 +[stream]
102 + destination = tcp:127.0.0.1:19999
103 +```
104 +
105 +[Restart the Agents](https://github.com/netdata/netdata/blob/master/docs/configure/start-stop-restart.md), and you are done!
106 +
107 +You should now be able to have a Local Dashboard that gets its metrics from Child instances, running through Cloudflare tunnels.
108 +
109 +> ### Note
110 +>
111 +> You can find the origin of this page in [this discussion](https://discord.com/channels/847502280503590932/1154164395799216189/1154556625944854618) in our Discord server.
112 +>
113 +> We thought it was going to be helpful to all users, so we included it in our docs.