Skip to main content
Hyper 8 Spacefun Videos

DS-Lite Selfhosting mit Cloudflare Tunnel

Hallo liebe BattleMech-Pilot:innen. In diesem  Video möchte ich euch zeigen, wie ihr mit einem   00:00
Cloudfare Argo Tunnel Selfhosting bei euch zu  Hause einrichten könnt. Das bietet sich z.B.   00:06
dann an, wenn ihr nur noch einen sogenannten  DS-Light Anschluss habt. Bei DS-Light handelt   00:13
es sich nämlich um eine abgespeckte Variante von  einem DSL-Anschluss, bei dem ihr gar nicht mehr   00:21
eine richtige IPv4 Adresse bekommt. Ihr habt  zwar hauptsächlich IPv6 und darüber könntet   00:26
ihr auch weiterhin Dienste im Internet anbieten,  die IPv4 Adresse hingegen teilt ihr euch mit ganz   00:32
vielen anderen Usern, die auch bei eurem Provider  einen Anschluss haben. Dadurch kannst du dann kein   00:39
NAT mehr machen, weil diese IPv4 Adresse bei  deinem Provider liegt und du kannst dann kein   00:46
Port-Forwarding mehr bei dir auf dem Router für  IPv4 einstellen. Das ist natürlich mega schlecht,   00:52
denn ihr könnt dann nicht mehr ein vollwertiges  Selfhosting bei euch zu Hause nutzen. Das machen   00:59
die natürlich extra, weil die IPv4 Adressen  so langsam knapp werden und sie dadurch ganz   01:05
viel Geld sparen. Also beim Abschluss eures  DSL-Vertrags legt bitte schon Werte darauf,   01:10
dass ihr einen vollwertigen DSL-Anschluss bekommt.  Falls das nicht der Fall ist, habt ihr aber jetzt   01:15
mit dieser Lösung, die ich euch heute vorstellen  möchte, trotzdem die Möglichkeit ein sicheres   01:21
und gutes Selfhosting einzurichten. Als Erstes  benötigen wir dazu eine eigene Domain und die   01:26
kannst du ganz einfach registrieren. Da gibt es  verschiedene Anbieter. Ich habe mich jetzt mal   01:34
für ionos entschieden, weil die ganz günstig sind  und da findest du hier auf ionos die Möglichkeit   01:38
Domains zu registrieren. Da kannst du dann hier  eine Wunschadresse angeben. Ich empfehle dir so   01:45
eine exotische Domain, die sind meistens recht  günstig. Also schaust du mal hier linuxcloud.icu 01:50
das wäre jetzt so eine exotische Domainendung.  Und wichtig ist, guckt, hier sagt er immer ja nur   02:00
0,09 € im Monat, das gilt aber nur für die  ersten 12 Monate. Wichtig ist was hier steht,   02:06
danach. Danach kommt nämlich der Preis zum Tragen  also 0,91 € im Monat. Diese .icu-Domain ist damit   02:13
immer noch richtig günstig, denn ihr zahlt dann  nachher nicht mal 12 € im Jahr dafür. Wenn ihr   02:22
jetzt mal schaut, hier gibt es z.B. welche die  sind mit 0,07 € hier am Anfang ganz günstig kosten   02:27
dann aber nachher 2,72 € im Monat. Oder hier 5,43  € im Monat. Also wählt eine günstige Domain wie   02:34
z.B. diese .icu-Domain. Ich habe das jetzt hier  schon mal vorbereitet, ich habe mir meine Domain   02:42
registriert. Meine Domain heißt jetzt bei mir  tuxwiz.xyz, das wäre die hier. Und die kann ich   02:47
dann hier unter Domains verwalten. Wichtig ist,  dass wir nachher hier diesen Punkt Nameserver   02:54
finden. Da ist jetzt meine Domain. Jetzt kann  ich hier in Cloudflare einen Account erstellen   03:00
und mich dort dann anmelden. Der sieht dann  erstmal noch recht leer aus und ich muss dann   03:08
hier über den Punkt Add Site meine Domain hier  in Cloudflare hinzufügen. Hier sage ich jetzt 03:12
tuxwiz.xyz 03:17
Continue. Ja sage ich hier.  Welchen Plan ich möchte,   03:22
da scrolle ich ganz runter und dann wähle  ich hier diesen Free Plan. Der kostet euch 03:31
nichts. Jetzt müssen wir die  DNS-Server entsprechend anpassen,   03:35
das ist noch ein ganz wichtiger Schritt.  Und wir müssen hier das sagt er hier,   03:43
Update your Nameservers, die müssen wir  jetzt hier bei unserer DNS-Verwaltung   03:47
entsprechend einrichten. Dazu sage ich jetzt hier  Nameserver und sage dann hier personalisierte   03:52
Nameserver verwenden. Und hier kann ich  jetzt diese Nameserver auch hier schon 03:59
reinpasten. Das wären jetzt zwei Nameserver.  Ich packe euch das ganze wie üblich auch immer   04:04
in so ein Cheat Sheet rein. Dann habt ihr die  Möglichkeit, nachher das entsprechend auch noch   04:12
mal nachzulesen. Sobald diese Nameserver also hier  eingetragen wurden, dann dauert es einen Moment,   04:18
denn er muss jetzt erstmal verifizieren, dass  die Nameserver auch wirklich übernommen werden   04:26
können. Also wartet da wirklich ein bisschen, das  kann bis zu einer Stunde dauern. Ich überspringe   04:31
das jetzt hier mal und melde mich dann gleich bei  euch wieder. Er ist jetzt hier immer noch nicht   04:35
ganz fertig, aber wir können jetzt hier schon mal  diese Recommendations durchgehen, die er uns hier   04:41
empfiehlt. Quickstart Guide, Review Settings,  Improve Security, Automatic HTTPS rewrites,   04:47
das möchten wir. Wir möchten, dass unsere Anfragen  automatisch auf HTTPS umgeschrieben werden und   04:56
damit auch mit SSL verschlüsselt sind. Da sage ich  hier also Save. Always use HTTPS, da sage ich auch   05:02
Ja, das möchte ich gerne. Ich möchte, dass alle  Anfragen verschlüsselt erfolgen und sage hier   05:12
also auch Save. Hier kann ich jetzt dann noch  auf Finish klicken. Jetzt können wir hier noch   05:17
mal schauen also bei meiner Domainverwaltung. Da  sind die Namserver ja bereits richtig eingetragen.   05:26
Hier sind diese zwei Nameserver, die er jetzt  erwartet von Cloudflare. Hier habe ich beide   05:33
hinzugefügt. Das kann ich jetzt auch prüfen mit  dem dig Befehl auf der Kommandozeile und das zeige   05:38
ich euch jetzt auch gerade mal, wie das geht. Hier  habe ich das schon mal vorbereitet. Also das ist   05:45
der Befehl dig, das ist ein DNS lookup Utility,  und hier gebe ich dann mit @ den Nameserver an,   05:50
den ich abfragen möchte. Da gibt es z.B. 9.9.9.9,  das ist ein öffentlicher Nameserver, der wird von   05:58
Quad9 betrieben und kann gratis genutzt werden,  ich nutze den zum Teil auch. Hier sage ich jetzt   06:05
noch +short, dass mir das Ergebnis in Kurzform  dargestellt wird und dann möchte ich nur den   06:12
Typ NS Abfragen. NS steht dabei für Nameserver. Es  gibt da verschiedene Query Types z.B. MX für Mail   06:19
Exchanger also deine Mailserver und NS wäre jetzt  der Nameserver, der auf dieser Domain hinterlegt   06:27
ist, und dann natürlich den Domainnamen in meinem  Fall tuxwiz.xyz. Das schicke ich jetzt mal ab und   06:34
hier sehe ich jetzt auch schon also der Nameserver  von Quad9, der sagt mir jetzt hier auch schon,   06:41
aha, das sind die beiden Cloudflare DNS-Einträge,  die ich hier hinterlegt habe. Also er erkennt das   06:46
schon und damit sollte tatsächlich dann Cloudflare  selber auch in der Lage sein in Kürze hier diese   06:54
Domains verwalten zu können. Jetzt ist es aber so,  dass z.B bei ionos standardmäßig schon mal ganz   07:02
viele DNS-Records erstellt werden und die müssen  wir, sobald das dann hier in der Verwaltung ist,   07:09
alle erst mal löschen, denn sonst  können wir nachher diesen Tunnel,   07:14
den wir ja verwenden wollen, gar nicht erst  einrichten. Also die Domain ist jetzt hier als   07:18
Active gekennzeichnet und damit kann ich schon  hier mit der Bearbeitung beginnen. Wichtig ist,   07:24
dass du hier als allererstes Mal unter DNS-Records  schaust, ob da keine a Records oder AAAA für IPv6   07:29
Records hier bereits bestehen. Denn was er macht  ist, er prüft beim Übernehmen der Domain von   07:38
ionos, ob da bereits DNS-Einträge gesetzt sind  und falls ja, dann übernimmt er die einfach,   07:44
damit das reibungslos weiterläuft bei deinem  bisherigen Provider. Aber wir wollen das ja jetzt   07:49
selber nutzen, das heißt wir müssen zumindest die  A-Records und die AAAA-Records für die Domain und   07:54
für www.meinedomain entfernen. Du kannst hier  natürlich die MX- Records, falls du möchtest und   08:00
die SPF-Einträge und autodiscover und so weiter,  die könntest du bestehen lassen und dann könntest   08:07
du auch bei ionos weiterhin auch auf diese Domain  E-Mailadressen einrichten. Das finde ich jetzt   08:13
noch eine ganz sinnvolle Kombination. Ich habe  das bei mir jetzt hier nicht gemacht, ich habe   08:18
also alle DNS-Records entfernt, denn ich möchte  diese Domain komplett unter meiner Kontrolle   08:21
haben. Für den Aufbau des Tunnels benötigen wir  jetzt als Nächstes eine App die heißt cloudlared   08:27
und die findest du hier auf Github. Ich habe euch  wie immer das Repository natürlich auch hier in   08:35
dem Cheat Sheet mit verlinkt. Wenn ihr auf unsere  Spacefun Community geht, das könnt ihr hier über   08:40
spacefun.ch/community, dann findet ihr dort  auch das Cheat Sheet mit all diesen wichtigen   08:47
Informationen, die ich dir hier auch erkläre. Also  ich bin jetzt hier auf dieser GitHub-Seite und da   08:52
findest du die Releases und wählst das aktuelle  Release für deine Plattform aus. Du siehst, es   08:58
gibt hier zum Teil auch Debian- oder RPM-Pakete.  Die sind allerdings für eine andere Plattform,   09:03
da musst du dann das richtige finden. Ich  wähle jetzt hier allerdings das Binary.   09:08
Das Binary heißt cloudflared-linux-amd64 und das  hat den Vorteil, dass es sich automatisch selbst   09:13
aktualisiert. Das ist beim Debian-Paket leider  nicht der Fall. Ich wähle also hier das Binary,   09:21
klicke auf Download und finde das dann hier in  meinem Downloads-Ordner. Wenn das der Fall ist,   09:27
dann kopiere ich mir das hier raus und packe  das bei mir in den persönlichen Ordner in einen   09:33
Ordner ~/bin und kann das dann dort auch immer  wieder ausführen. Damit ich das auch jeweils in   09:37
der Shell wiederfinde, kann ich die sogenannte  PATH-Variable hier erweitern. Ich kann jetzt   09:46
mal hier echo $PATH eingeben und da seht ihr die  aktuelle PATH-Variable. PATH= in diesen Ordnern,   09:52
da findet ihr all diese Befehle drin, die  automatisch ohne Angabe dieses kompletten   09:58
Pfades aufgerufen werden können. Also  wenn du jetzt mal guckst ls -al /usr/bin,   10:05
diese ganzen Dinger kannst du jetzt überall egal  wo du bist in der Shell einfach aufrufen. Z.B.   10:11
zip kann ich von jedem beliebigen Ort in der Shell  aufrufen. Das geht nur mit Befehlen, die in dieser   10:16
sogenannten PATH-Vriable enthalten sind. Du hast  jetzt gesehen, dass das bin-Verzeichnis in meinem   10:21
Home noch nicht in dieser PATH-Variable drin  ist. Das können wir aber ändern, indem wir hier   10:28
diese PATH-Variable erweitern. Dazu kann ich  mir hier in die ~/.bashrc. Das ist die Datei,   10:33
die beim Login ausgeführt wird, also gesourced  wird. Da kann ich das noch hinzufügen. Ich sage   10:39
jetzt also nano ~/.bashrc, scrolle da ganz ans  Ende und füge dann hier entsprechend diese Zeilen   10:45
hinzu. Dabei handelt es sich um eine for-Schleife  die schaut, ob in deinem HOME-Verzeichnis ein .bin   10:53
Verzeichnis oder ein bin-Verzeichnis existiert  und falls ja, falls dieses Verzeichnis existiert,   11:00
dann erweitert der diese Pfadvariable um dieses  bin-Dirs. Ich sage jetzt hier also CTRL+O,   11:06
Enter und CTRL+X, beenden. Jetzt kann ich  die wieder neu sourcen. Ich könnte jetzt   11:13
einmal eine neue Shell starten oder ich sage  source ~/.bashrc und habe das dann schon drin.   11:17
Jetzt kann ich noch mal echo $PATH eingeben  und sehe jetzt hier er hat gefunden. Es gibt   11:23
/home/astronaut/bin also das hat er direkt zum  Pfad hinzugefügt, das ist schon mal super. Jetzt   11:28
kann ich in ~/bin gehen. Das ist natürlich jetzt  noch nicht ausführbar, ich mache jetzt chmod +x   11:34
cloudflared-linux-amd64 und schon ist das Ganze  auch ausführbar. Jetzt geht es an die eigentliche   11:39
Einrichtung des Tunnels und dazu musst du dich  erstmal anmelden. Das kannst du halt hier mit   11:45
diesem Befehl cloudlflared. Ich könnte jetzt  auch noch einen Link machen ln -s cloudflared,   11:50
das ist ein symbolischer Link cloudflared-linux-  amd64 nach cloudflared und dann kann ich einfach   11:56
cloudflared ausführen und muss nicht jedes Mal  diesen langen cloudflared-linux-amd64 eingeben.   12:05
Ich sag jetzt also cloudflared tunnel login. Jetzt  öffnet sich der Browser und jetzt kann ich hier   12:11
diese Domain entsprechend hier zuordnen, also  Tunnel für tuxwiz.xyz. Da steht jetzt natürlich   12:17
deine Domain. Ich sage jetzt hier also Save  und damit ist der Tunnel dann entsprechend   12:23
auch schon autorisiert. Dieses Fenster kann ich  jetzt hier auch schon schließen. Als Nächstes   12:28
kann ich jetzt diesen Tunnel erstellen, und  zwar mit dem Befehl cloudflared tunnel create   12:35
meindomaintunnel. Das füge ich jetzt hier mal ein.  Das meindomaintunnel musst du natürlich an deine   12:40
Domain anpassen. In meinem Fall wäre das jetzt  z.B. cloudflared tunnel create tuxwizxyztunnel.   12:46
Damit habe ich jetzt einen Tunnel erstellt und er  zeigt mir hier auch eine UUID an die wir jetzt im   12:55
Folgenden weiter benötigen. Die kopierst du  dir am besten raus, denn die benötigen wir   13:01
jetzt gleich in den kommenden Befehl. Jetzt  kopiere ich mir das Zertifikat, was er beim   13:06
Login erstellt hat in diese UUID, damit wir klar  wissen, wie die zugeordnet ist. Also hier sage ich 13:12
cp $HOME/.cloudflared/cert.pem nach  $HOME/.cloudflared/ und dann diese UUID.pem,   13:19
also MEINE_TUNNEL_ID ersetze ich jetzt jeweils  hier mit dieser UUID. Das habe ich jetzt gemacht.   13:28
Im Unterordner .cloudflared finde ich jetzt also  dieses json-File. Das hat er eben erstellt bei   13:34
dem Befehl cloudfared tunnel create und dieses  gleichnamige pem-File. Das ist die Voraussetzung,   13:40
um diesen Tunnel jetzt auch zu starten, also  aufzubauen und systemweit zu aktivieren. Das   13:47
machen wir jetzt hier als Nächstes.  Dazu erstelle ich jetzt erstmal ein   13:53
Verzeichnis in /etc und zwar sudo mkdir -p  /etc/cloudflared und erstelle dort dann eine   13:56
zentrale Konfigurationsdatei dazu gebe ich den  Befehl sudo nano /etc/cloudflared/config.yml   14:03
ein und kann dann hier den Inhalt hier aus  meinem Cheat Sheet reinkopieren. Das paste   14:12
ich hier mal rein. Als Tunnel gebe ich jetzt hier  wieder an meindomaintunnel also tuxwizxyztunnel 14:19
und hier diese Daten zum credentials-file  und origincertpath muss ich natürlich   14:27
entsprechend anpassen. Mein Benutzer hier auf  meinem System heißt jetzt astronaut und in dem   14:32
ordner ~/.cloudflared gibt's halt  dieses json-File und hier unten auch 14:38
astronaut und jetzt muss ich natürlich  diese Tunnel-ID entsprechend ersetzen   14:42
durch das was wir vorher angezeigt bekommen  haben. Da gehe ich jetzt mal her und sage   14:49
jetzt hier überall, wo MEINE_Tunnel_ID  drin steht, da kommt jetzt diese UUID 14:54
rein und dann können wir hier unten mit der  Domainkonfiguration fortfahren. Ich möchte   15:00
jetzt hier einen Hostnamen definieren,  das wäre jetzt natürlich tuxwiz.xyz.   15:08
Das entspricht deiner Domain tuxwiz.xyz  und das wird weitergeleitet auf localhost   15:12
Port 80. Da muss ich dann natürlich  mein Selfhosting auf dem localhost   15:19
Port 80 laufen lassen und hier gebe ich  jetzt hier auch noch www.tuxwiz.xyz an, 15:23
dann haben wir beides auch schon abgefangen. xyz,  jetzt sage ich Ctrl oder Strg O + X und damit ist   15:29
diese Datei auch schon geschrieben. Jetzt müssen  wir noch die DNS-Route einstellen und das erfolgt   15:37
mit cloudflared tunnel route dns meindomaintunnel  nach meinedomain.tld. Das können wir hier mal   15:44
eingeben, und zwar muss ich da natürlich auch  wieder meindomaintunnel durch tuxwiztunnel   15:51
ersetzen. tuxwiztunnel und meine Domain wäre  jetzt tuxwiz.xyz. tuxwiz.xyz. Jetzt wird diese   15:56
Route also, da wird jetzt ein cname tuxwiz.xyz,  der routet den jetzt auf meinen Tunnel. Das   16:08
hat er jetzt hier in dem Fall auch schon sauber  erstellt. Das gleiche mache ich jetzt auch noch   16:13
für www.tuxwiz.xyz und gebe das hier entsprechend  ein. Auf den gleichen Tunnel route ich jetzt auch   16:17
www. Jetzt möchten wir natürlich noch dass das  Ganze beim Systemstart auch aktiviert wird und   16:23
dazu kann ich hier diesen Befehl cloudflared  service install verwenden. Ich kopiere mir den   16:30
mal also sudo $HOME/bin/cloudflared . Da muss  ich den Pfad jetzt wieder komplett angeben,   16:36
denn im Root-Kontext ist die PATH-Erweiterung  die wir vorher gemacht haben natürlich nicht   16:43
bekannt. Ich sage jetzt hier also sudo  $HOME/bin/cloudflared service install   16:47
und schon ist dieser systemd-Dienst hier bereits  installiert. Damit wir jetzt diesen Service auch   16:52
starten können, muss natürlich auch irgendetwas  auf Port 80 lauschen., irgendein Webserver oder   16:59
deine Cloud. Dazu kannst du z.B. die Nextcloud  mit snap installieren. Schau dir dazu unbedingt   17:04
auch mal mein Video an, oder auch einfach einen  einfachen Webserver. Ich installiere jetzt mal   17:09
hier für das Demo einen Apache-Webserver. Dazu  gebe ich sudo sudo apt install apache2 ein und   17:14
dabei wird dann schon mein Webserver hier  im Hinter grund installiert. Da muss ich   17:25
mal die Konfiguration natürlich noch ein bisschen  anpassen, damit er auch tatsächlich dann auch auf   17:30
diesen Servernamen lauscht, und da gebe ich hier  in dieser Datei in der Default-Konfigurationsdatei   17:36
einfach mal als ServerName tuxwiz.xyz ein, und  dann kann ich hier z.B. noch ein ServerAlias 17:41
www.tuxwiz.xyz, sage Ctrl+O und Ctrl+X und damit  ist diese Konfiguration auch schon gespeichert.   17:52
Jetzt kann ich den Service noch neu starten, also  den Webserver sudo systemctl restart apache2 und   18:04
jetzt sollte auch hier auf localhost bereits mein  Webserver lauschen. Den möchte ich jetzt natürlich   18:15
über meinen Tunnel erreichbar machen und dazu  starte ich jetzt hier diesen cloudfared Service   18:21
den wir vorhin eingerichtnet haben. sudo systemctl  start cloudflared. Da kann ich jetzt auch noch ein   18:27
status drauf machen, status und kann jetzt hier  sehen, ah, das sieht ganz gut aus. Jetzt schauen   18:33
wir doch mal, ob auf meiner Domain tuxwiz.xyz  auch schon meine Webseite kommt. Und siehe da,   18:39
das ist meine Webseite die ist verschlüsselt  die läuft hier in meinem Selfhosting direkt   18:45
auf dieser Maschine. Ich kann auch mal  www davor eingeben dann schauen wir mal,   18:51
das geht also auch. Also hier hast du die  Möglichkeit ohne großen Aufwand einen sicheren   18:55
Tunnel einzurichten. Du musst noch nicht mal  irgendwas an deinem Router konfigurieren. Du   19:00
kannst gerade loslegen und hast dein Selfhosting  so ganz einfach im Internet verfügbar gemacht.   19:05
Falls du Fragen zur Einrichtung hast,  komme in unsere Telegram-Community,   19:11
einfach hier auf spacefun.ch Telegram klicken  und schon bist du drin und wir helfen dir gerne   19:16
weiter. Dort findest du auch das CheatSheet also,  all diese Befehle, die ich hier genannt habe,   19:22
wieder und kannst es für dich nach und  nach nachbauen. Ich bin gespannt auf deine   19:26
Erfahrung und freue mich auf dein Feedback  auch in den Kommentaren. Bis bald. Tschüss. 19:32
Hello BattleMech pilots. In this video, I want to show you how 00:00
to set up self-hosting at home using a Cloudfare Argo Tunnel. This is useful, for example 00:06
, if you only have a so-called DS-Light connection. DS-Light is 00:13
a slimmed-down version of a DSL connection that no longer 00:21
provides a proper IPv4 address. While you primarily have IPv6, which means 00:26
you could continue to offer internet services, you share the IPv4 address with 00:32
many other users who also have a connection with your provider. This means you can no 00:39
longer use NAT, because this IPv4 address is held by your provider, and you can no longer 00:46
configure port forwarding for IPv4 on your router. This is obviously extremely bad, 00:52
because you will no longer be able to use full-fledged self-hosting at home. 00:59
They do this on purpose, of course, because IPv4 addresses are slowly becoming scarce, and this way they 01:05
save a lot of money. So when you sign your DSL contract, please make sure 01:10
you get a full-fledged DSL connection. If that's not the case, you still have 01:15
the option of setting up secure and reliable self-hosting with this solution that I'd like to introduce to you today. 01:21
First of all, we need our own domain, and 01:26
you can register one very easily. There are various providers. I've chosen 01:34
ionos because they're very affordable, and you can 01:38
register domains here on ionos. You can then enter your desired address. I recommend 01:45
an exotic domain; they're usually quite inexpensive. Take a look here: linuxcloud.icu; 01:50
that would be an exotic domain extension. And the important thing is, look, it always says only 02:00
€0.09 a month, but that only applies for the first 12 months. What's important is what it says 02:06
after that. After that, the price applies, i.e. €0.91 a month. This .icu domain is 02:13
still really cheap because you'll be paying less than €12 a year for it. If you 02:22
take a look, there are some here, for example, that start out really cheap at €0.07 02:27
but then cost €2.72 a month. Or here it's €5.43 a month. So choose a cheap domain like 02:34
this .icu domain. I've already prepared this here; I've 02:42
registered my domain. My domain is now called tuxwiz.xyz, which would be this one. And I can 02:47
then manage it here under Domains. The important thing is that we 02:54
find this point called Nameserver later. That's where my domain is now. Now I can create an account here in Cloudflare 03:00
and log in there. It will look pretty empty at first, and then I have 03:08
to add my domain here in Cloudflare using the Add Site point. Here I say 03:12
tuxwiz.xyz 03:17
Continue. I say Yes, I say here. To find out which plan I want, 03:22
I scroll all the way down and then select this Free Plan. It doesn't cost you 03:31
anything. Now we need to adjust the DNS servers accordingly; 03:35
that's a very important step. And we 03:43
need to set them up accordingly in our DNS management, 03:47
as it says here: Update your Nameservers . To do this, I'll say Nameservers here and then say 03:52
Use personalized nameservers here. And I can now paste these nameservers in here 03:59
. That would be two nameservers. As usual, I'll put the whole thing 04:04
in a cheat sheet for you. Then you'll have the option 04:12
to read it again later. Once these nameservers have been entered here, it will take a moment 04:18
because it has to verify that the nameservers can actually be adopted 04:26
. So wait a bit; it can take up to an hour. I'll skip 04:31
this for now and get back to you shortly. It's still not 04:35
quite finished, but we can go through the recommendations it 04:41
's giving us here. Quickstart Guide, Review Settings, Improve Security, Automatic HTTPS rewrites, 04:47
that's what we want. We want our requests to be automatically rewritten to HTTPS and 04:56
so that they are also encrypted with SSL. So I say Save here. Always use HTTPS, I also say 05:02
Yes, I would like that. I want all requests to be encrypted and so I say 05:12
Save here too. Here I can now click Finish. Now we can take another 05:17
look here, at my domain management. The name servers are already entered correctly. 05:26
Here are the two name servers that it now expects from Cloudflare. I have 05:33
added both here. I can now check this with the dig command on the command line and 05:38
I will show you how to do it now. I have already prepared it here. So this is 05:45
the dig command, which is a DNS lookup utility, and here I specify the name server 05:50
that I want to query with @. For example, there is 9.9.9.9, which is a public name server 05:58
operated by Quad9 and can be used free of charge; I use it sometimes too. Here I 06:05
also say +short so that the result is displayed in short form and then I only want 06:12
to query the NS type. NS stands for name server. There are different query types, for example MX for mail 06:19
exchanger, i.e. your mail server, and NS would be the name server that 06:27
is stored on this domain, and then of course the domain name, in my case tuxwiz.xyz. I'll send that off now and 06:34
here I can see the name server for Quad9, and it tells me, 06:41
aha, these are the two Cloudflare DNS entries that I have stored here. So it recognizes it 06:46
and with that Cloudflare itself should actually be able to manage these domains soon 06:54
. But the thing is, with ionos, for example, a 07:02
lot of DNS records are created by default and we have 07:09
to delete them all as soon as it's in the administration here, otherwise we 07:14
won't be able to set up the tunnel that we want to use. So the domain is now 07:18
marked as active and I can start editing it here. It's important 07:24
that you first check under DNS records to see if there are any A records or AAAA records for IPv6 07:29
records already set. Because what it does is, when you take over the domain from 07:38
ionos, it checks whether any DNS records have already been set, and if so, it simply takes them over 07:44
so that everything continues to run smoothly with your previous provider. But we want 07:49
to use it ourselves now, which means we have to at least remove the A records and the AAAA records for the domain and 07:54
for www.mydomain. You can of course leave the MX records here if you want, as well as 08:00
the SPF records and autodiscover and so on, and then 08:07
you could continue to set up email addresses for this domain with ionos. I think that's 08:13
a really useful combination. I didn't do that here; I 08:18
removed all DNS records because I want 08:21
to have complete control over this domain. To set up the tunnel, we now need an app called cloudlared 08:27
, which you can find here on Github. As always, I've 08:35
included a link to the repository in the cheat sheet. If you go to our Spacefun Community, which you can do here at 08:40
spacefun.ch/community, you'll also find the cheat sheet there with all the important 08:47
information, which I'll explain to you here. So I'm now on this GitHub page, and there 08:52
you'll find the releases. Select the latest release for your platform. As you can see, there 08:58
are some Debian or RPM packages here too. However, these are for a different platform, 09:03
so you'll have to find the right one. I'll select the binary here. 09:08
The binary is called cloudflared-linux-amd64, and this has the advantage that it updates itself automatically 09:13
. Unfortunately, this isn't the case with the Debian package. So I select the binary here, 09:21
click Download, and then find it in my Downloads folder. If that's the case, 09:27
I'll copy this out and put it in my personal folder in a 09:33
folder called ~/bin and then I can run it there again and again. So that I can always 09:37
the shell, I can expand the so-called PATH variable here. I can now 09:46
type echo $PATH here and there you can see the current PATH variable. PATH= in these folders, 09:52
there you will find all the commands that 09:58
can be called automatically without specifying the complete path. So if you now look at ls -al /usr/bin, 10:05
you can now call all of these things anywhere in the shell, no matter where you are. For example, 10:11
I can call zip from any location in the shell. This only works with commands that 10:16
are contained in this so-called PATH variable. You have now seen that the bin directory in my 10:21
home directory is not yet in this PATH variable. But we can change that by 10:28
expanding this PATH variable. To do this, I can look in the ~/.bashrc here. This is the file 10:33
that is executed when I log in, i.e. is sourced. I can add this there. So I'll say 10:39
nano ~/.bashrc, scroll all the way to the end, and then add these lines 10:45
. This is a for loop that checks whether a .bin 10:53
directory or a bin directory exists in your HOME directory, and if so, 11:00
it extends the path variable to include the bin directory. I'll say CTRL+O, 11:06
Enter, and CTRL+X and exit. Now I can resource it. I could 11:13
start a new shell, or I could say source ~/.bashrc, and that would already be there. 11:17
I can type echo $PATH again and see that it found it. There's 11:23
/home/astronaut/bin, so it's added that directly to the path, which is great. Now 11:28
I can go to ~/bin. Of course, that's not executable yet, so I'll do chmod +x 11:34
cloudflared-linux-amd64, and the whole thing will be executable. Now it's time to actually 11:39
set up the tunnel, and to do that you first have to log in. You can do that here with 11:45
the command cloudlflared. I could also create a link: ln -s cloudflared. 11:50
This is a symbolic link to cloudflared-linux-amd64 to cloudflared, and then I can simply 11:56
run cloudflared and don't have to type in this long cloudflared-linux-amd64 every time. 12:05
I'll say cloudflared tunnel login. The browser will now open, and I can 12:11
assign this domain here, so tunnel for tuxwiz.xyz. 12:17
Your domain will now be there, of course. I'll say Save here, and the tunnel will then be 12:23
authorized. I can close this window now. Next, 12:28
I can create this tunnel with the command cloudflared tunnel create 12:35
mydomaintunnel. I'll insert this here. You will of course have 12:40
to adapt the mydomaintunnel to your domain. In my case, that would be, for example, cloudflared tunnel create tuxwizxyztunnel. 12:46
I've now created a tunnel, and it's showing me a UUID, which we 12:55
'll need next. It's best to copy this out, as we'll need it 13:01
in the next command. Now I'm going to copy the certificate it 13:06
created during login into this UUID so we know exactly how it's assigned. So, I'm going to say 13:12
cp $HOME/.cloudflared/cert.pem to $HOME/.cloudflared/ and then this UUID.pem, 13:19
so I'm going to replace MY_TUNNEL_ID with this UUID. I've done that. 13:28
In the .cloudflared subfolder, I now find this json file. It created this with 13:34
the command cloudflared tunnel create, and this pem file of the same name. This is what we need to do 13:40
to start this tunnel, i.e., to set it up and activate it system-wide. 13:47
We'll do that next. To do this, I first create a 13:53
directory in /etc, namely sudo mkdir -p /etc/cloudflared, and then create a 13:56
central configuration file there. To do this, I 14:03
enter the command sudo nano /etc/cloudflared/config.yml, and then I can copy the contents from my cheat sheet into it. 14:12
I'll paste it here. For the tunnel, I'll now enter mydomaintunnel, so tuxwizxyztunnel 14:19
, and here I need to enter this data for the credentials file and origincertpath. 14:27
adjust accordingly. My user here on my system is now called astronaut and in the 14:32
folder ~/.cloudflared there is this JSON file and also 14:38
astronaut down here and now I obviously have to replace this tunnel ID 14:42
with what we saw before. I'll go there and say 14:49
everywhere where MY_Tunnel_ID is there, this UUID will go 14:54
in and then we can continue down here with the domain configuration. I would like 15:00
to define a hostname here, which would of course be tuxwiz.xyz. 15:08
That corresponds to your domain tuxwiz.xyz and it will be forwarded to localhost 15:12
port 80. So I obviously have to 15:19
run my self-hosting on localhost port 80 and here I also enter www.tuxwiz.xyz, 15:23
then we've already intercepted both. xyz, now I say Ctrl or Strg O + X and 15:29
this file is already written. Now we need to set up the DNS route, which is done 15:37
with cloudflared tunnel route dns mydomaintunnel to mydomain.tld. We can 15:44
enter that here. Of course, I have to 15:51
replace mydomaintunnel with tuxwiztunnel, and my domain would now be tuxwiz.xyz. tuxwiz.xyz. Now this 15:56
route will have a cname tuxwiz.xyz, which will route it to my tunnel. 16:08
In this case, it has already been cleanly created. I'll do the same 16:13
for www.tuxwiz.xyz and enter it here accordingly. I'll also route 16:17
www. to the same tunnel. Now, of course, we want the whole thing to be activated when the system starts, and 16:23
for that I can use the command cloudflared service install. I'll just copy it over, so I'll 16:30
just copy it over: sudo $HOME/bin/cloudflared. I have to specify the complete path again 16:36
because the PATH extension we made before is obviously not 16:43
known in the root context. So I now say sudo $HOME/bin/cloudflared service install 16:47
and this systemd service is already installed. For us to 16:52
start this service, something has to be listening on port 80, some web server or 16:59
your cloud. You can do this with snap, for example. Be sure to 17:04
watch my video on this, or just a simple web server. I'm going to install 17:09
an Apache web server for the demo. To do this, I'll enter sudo sudo apt install apache2 and 17:14
my web server will then be installed in the background. I 17:25
obviously need to tweak the configuration a bit so that it actually 17:30
listens on this server name. In the default configuration file, I 17:36
simply enter tuxwiz.xyz as the server name. I can then add a server alias like 17:41
www.tuxwiz.xyz, say Ctrl+O and Ctrl+X, and the configuration is saved. 17:52
Now I can restart the service, i.e. the web server: sudo systemctl restart apache2. 18:04
My web server should now be listening here on localhost. I would like to 18:15
make it accessible via my tunnel, of course, and to do this, I'm going to start this cloudflared service 18:21
that we set up earlier: sudo systemctl start cloudflared. I can also 18:27
add a status to it, status, and I can see here, oh, that looks pretty good. Now 18:33
let's see if my website is already on my domain tuxwiz.xyz. And look, 18:39
this is my website, it's encrypted, and it's running on my self-hosted server directly 18:45
on this machine. I can also type www in front of it, and we'll see, 18:51
so that works too. So here you have the option 18:55
of setting up a secure tunnel without much effort. You don't even have to configure anything on your router. You 19:00
can get started right away and have easily made your self-hosted server available on the internet. 19:05
If you have any questions about setting it up, join our Telegram community. 19:11
Just click on Telegram here at spacefun.ch, and you're in, and we'll be happy to help you 19:16
. There you'll also find the cheat sheet, all these commands I've mentioned here. 19:22
again and you can recreate it for yourself bit by bit. I'm curious about your 19:26
experience and look forward to your feedback in the comments. See you soon. Bye. 19:32

Mit einem DS-Lite-Anschluss ist klassisches Selfhosting oft schwierig, da dir keine eigene öffentliche IPv4-Adresse zur Verfügung steht und Portweiterleitungen nicht möglich sind. Hier kommt der Cloudflare Tunnel ins Spiel: Damit kannst du trotzdem eigene Dienste wie eine Website oder Nextcloud sicher aus dem Internet erreichbar machen, und das sogar SSL-verschlüsselt und ausschließlich über HTTPS.

Du benötigst lediglich eine eigene Domain, die du dann bei Cloudflare hinzufügst und die Nameserver entsprechend umstellst. Achte darauf, dass keine alten DNS-Einträge vorhanden sind. Anschließend installierst du den Cloudflare-Client auf deinem Server, am besten als selbstaktualisierendes Programm.

Mit diesem Client meldest du dich bei Cloudflare an, erstellst einen Tunnel und konfigurierst ihn so, dass Anfragen auf deine Domain automatisch an den gewünschten lokalen Dienst, zum Beispiel einen Webserver auf Port 80, weitergeleitet werden. In der Konfigurationsdatei legst du fest, welche Domains auf welchen lokalen Port zeigen. Der Cloudflare-Dienst sorgt dafür, dass der Tunnel beim Systemstart automatisch aktiviert wird.

Mit dieser Lösung erreichst du deinen Heimserver trotz DS-Lite zuverlässig und verschlüsselt aus dem Internet, ohne dich mit komplizierten Netzwerkeinstellungen oder Portweiterleitungen auseinandersetzen zu müssen. Das ist eine flexible und sichere Lösung für alle, die trotz eingeschränkter Internetanschlüsse nicht auf Selfhosting verzichten wollen.

Navigation

Video Player