{"version":"https:\/\/jsonfeed.org\/version\/1","title":"itsg.host","home_page_url":"https:\/\/itsg.host","description":"The ramblings of a humble Ghost on the internet","icon":"\/assets\/ghost-blue-9f377306.png?src=true","items":[{"content_html":"<p>The post COVID-19 lockdown period we are currently in here in the UK has lead to many new experiences all round, but\ntoday I experienced one from the most unlikely of sources in a way I never expected.<\/p>\n<p>The introduction of the track and trace system by the NHS has left me with many security and privacy concerns floating around in my head.\nThe news from the government the other week that they were finally adapting Apple and Google's decentralised APIs for contract tracing in the official app was welcome indeed,\nbut the interim system of it all being done over the phone has been far from ideal.\nI've already known of at least one confirmed case of a phishing call claiming to be from NHS Track &#x26; Trace team attempting to extract personal details,\nand with so much information on offer with people so afraid of everything that's going on,\nI don't think it'll be long before we see more of this type of scam appearing.<\/p>\n<p>The re-opening of pubs has also presenting a huge can of worms for data protection as pubs are required to keep the name, address, and contact details of the lead member of a group of people,\nwith many venues deciding they need to keep it for everyone just to be certain.\nThis presents some pretty obvious questions:<\/p>\n<ul>\n<li>What is the final scope of the data?<\/li>\n<li>How is that data stored?<\/li>\n<li>How long is it kept for?<\/li>\n<li>Who is responsible for ensuring it is securely destroyed when it is no longer relevant?<\/li>\n<\/ul>\n<p>Whilst all of these are important individually, even as somebody who takes their privacy very seriously and often lambastes others over their lax practices,\nI am willing to put all those concerns aside in the public interest whilst a better system is under development.<\/p>\n<p>All that however is probably a topic for a separate article, because what I came across today was so unexpected and out there that I initially didn't believe it,\nand have since been unable to stop thinking about it, as well as a bemusement at peoples responses.<\/p>\n<p>So what I hear you ask is so heinous?\nWell a venue I regularly go to for a community event also takes the form of a nightclub by evening.\nThey have decided that the best way to do track and trace is to sign everybody who comes up to their door ID system,\nsomething that I had not previously been aware of having never been to the venue in an evening.\nThis system validates your government issued ID, crosschecking the details on it,\nand verifying through the use of a doorman that it is for the person presenting it.\nThe name and date of birth are then dutifully stored alongside a fingerprint, so they can be recalled in the future and avoid the need for ID.\nA brief conversation revealed this to be a system called <a href=\"https:\/\/www.nightclub.co.uk\/\">Scannet<\/a> made specifically for the nightclub industry.<\/p>\n<p>Now, I&#39;ll confess, my initial reaction to this was &quot;huh, that&#39;s pretty neat&quot;.\nIt certainly wasn&#39;t a system I wanted to be a part of,\nbut from a technical standpoint it has some merits as a quick, reliable way to assert somebodies identity.\nThe big question I had, &quot;What happens if you don&#39;t wish to provide a fingerprint?&quot;.\nAfter all, biometrics are some of the most genitive data we can readily provide if only for the fact that we have no way of changing them.\nA cursory search of the Information Commissioner&#39;s Office site revealed that biometrics used for identification as a <a href=\"https:\/\/ico.org.uk\/for-organisations\/guide-to-data-protection\/guide-to-the-general-data-protection-regulation-gdpr\/special-category-data\/what-is-special-category-data\/\">special category of data<\/a>\nafforded extra protection by the GDPR.\nThey also link to an <a href=\"https:\/\/ec.europa.eu\/justice\/article-29\/documentation\/opinion-recommendation\/files\/2012\/wp193_en.pdf\">opinion from the Article 29 Data Protection Working Party<\/a>\nwhich helped draft the legislation providing specific examples for membership services using biometrics:<\/p>\n<blockquote>\n<p>In the absence of other alternative legitimate grounds, a biometric authentication system could be used to control access to a video club only if the customers are free to decide whether to avail themselves of the said system. This means that alternative, less privacy-intrusive mechanisms must be made available by the movie club owner. Such a system will permit a customer who is unwilling or unable to undergo fingerprinting because of his\/her personal circumstances to dissent. The sole choice between not using a service and giving one\u2019s biometric data is a strong indicator that the consent was not freely given and cannot be considered as legitimate ground.<\/p>\n<p>-- <cite><a href=\"https:\/\/ec.europa.eu\/justice\/article-29\/documentation\/opinion-recommendation\/files\/2012\/wp193_en.pdf\">00720\/12\/EN WP193, Opinion 3\/2012 on developments in biometric technologies, Page 11<\/a><\/cite><\/p>\n<\/blockquote>\n<p>I think it is pretty clear from this quote alone that an alternative biometric identification must be provided in cases such as this.\nThe opinion also provides plenty of additional examples agreeing with this interpretation,\nas well as some examples of when providing an alternative would not be considered necessary,\nfor example in the control of hazardous materials such as pathogen samples.<\/p>\n<p>After checking myself to make sure this wasn't just a tinfoil hat incident as I seem to be particularly prone to,\nwhich this admittedly cursory research seemed to support, I decided to ask if there was an alternative.\nNow given what I've learnt so far, and knowing some members attending this event may be considered vulnerable or not wish to be later identified,\nI assumed I would get a reasonable and proportioned response with the possibility for sensible discussion around what could be done.<\/p>\n<p>The response I got from the event organiser and venue owner, who I am choosing not to identify as it is not relevant to the larger discussion,\nwell it was not what I would call satisfactory.\nI am including the full message for the sake of transparency:<\/p>\n<blockquote>\n<p>No it\u2019s our operational policy and governed by GDPR, if people don\u2019t like it, we say thank you but no thank you and turn them away.<\/p>\n<p>A lot of big clubs use the Scannet ID system. It also takes a photo of you as you enter to ensure your who you say you are.\nIt also stops people using other ID to gain access.<\/p>\n<p>We\u2019ve over 38,000 people on there to date and it\u2019s been in operation with the business for 3 years<\/p>\n<\/blockquote>\n<p>Now, there are a number of issues with this statement, which I shall address:<\/p>\n<ul>\n<li>Despite a request for the full policy showing GDPR compliance, non was provided.\nAdditionally, applying the logic from the working group opinion, it would not be possible for this policy to comply with GDPR as consent cannot be provided as a legitimate ground for processing due to a lack of genuine choice.<\/li>\n<li>In my 4.5 years as a near full time event technician, I have never encountered such a system at any other venue, but I don't club much so will concede this point.<\/li>\n<li>The photo simply proves after the fact who it was if a comparison can be made.\nSome level of facial recognition may also be performed on the official ID presented to match against a live feed, but that was not clarified, and would further be subject to the opinions of the working group above.<\/li>\n<li>A fingerprint does not stop somebody using a false ID to gain entry.\nThe only assertion that can be made is it is the same person returning as first presented the ID, and the ID has not been used before if OCR\/RFID scanning is performed on it.<\/li>\n<\/ul>\n<p>The last point I will address separately as it deserves further consideration.\n38,000 enrollments is a <em>lot<\/em> of biometric data, making it a pretty valuable target security wise.\nThe Scannet website provides little to no information about how this is stored,\nalthough given it is a future matching system it will have to store a trained model to compare against in the future.\nI do not know enough about biometrics to know how this can be done,\nso I shall accept on trust that this is a one way hash system that cannot be reverse engineered to a full image.\nEven assuming good faith though, it is still a lot of personal data and official ID on file,\nand at some point in this process the scanner will need to acquire a full scan image in order to perform the hashing and comparison.<\/p>\n<p>The large number does however pull into question the retention time of this data,\nhow long is it considered appropriate to keep a copy of somebodies ID, photo and fingerprint on file after they last visited a venue.\nWhat audits are in place to ensure that if somebody hasn't visited the venue in a number of months their data is securely destroyed?\nIf the data is kept for so long, what limits the scope it can be used for to just the original purpose as per GPDR?<\/p>\n<p>Some of these questions I put forward in the group chat, only to be told by several others this was the system and that's how it was going to operate.\nIt was at this point I decided that I had been directed towards the door, and it was time for me to use it,\nwhich I did with great regret as I consider many of the people I only see in that group as friends.\nI remained amenable and invited those involved to discuss it further in a more appropriate setting outside of the main group,\nas of the time of writing I have not been approached.\nThe issues raised above may well have been resolved after I had decided to leave, but I would not have seen them.<\/p>\n<p>This whole incident though has raised one bigger question in my mind.\nIf businesses are collecting all this information specifically against the laws that have been put in place to protect consumers,\nand are unwilling to listen when the issue is raised, then what power do we have to alter them.\nYes, I could approach the ICO with my concerns, and they may well take action,\nalthough that seems unlikely and would involve a significant amount of time and energy on my part.\nIf action was taken, what would be the ultimate outcome?\nIf I was to hazard a guess in this case I would be barred from the venue, or if not certainly unwelcome back there,\nsomewhat defeating the purpose of the point I was trying to make.\nUltimately, even with the law behind us, we have no real power to control our data here.<\/p>\n<p>The irony of all this, if there hadn't been a debate and just a simple \"oh, we can do it this way\", I probably wouldn't have cared.\nMy grief is not with the system itself, which as I said earlier, I thought was pretty cool,\nit was with the complete lack of choice over what I data I can choose to give.\nEven just the choice of a simple opt-out with an alternative system, as recommended, would have solved all of the issues.\nInstead, I now find my position within the group untenable, and as such have had to walk away from a group I care about.<\/p>","url":"https:\/\/itsg.host\/2020\/fingerprints-really","title":"Fingerprints, Really?","date_modified":"2020-07-11T00:00:00.000Z","tags":[]},{"content_html":"<p>A few weeks ago I decided I wanted to setup some proper livestreaming for myself. I didn't have anything particular in\nmind with what I wanted to stream or who to, I just wanted the ability do so without fear of censorship, tracking or\nadverts.<\/p>\n<hr>\n<p>This is part one of a three part series:<\/p>\n<ol>\n<li><a href=\"\/2022\/live-itsg-host-part-1\" class=\"\">Current solutions<\/a><\/li>\n<li><a href=\"\/2022\/live-itsg-host-part-2\" class=\"\">New technologies<\/a><\/li>\n<li><a href=\"\/2022\/live-itsg-host-part-3\" class=\"\">Building your own streaming service<\/a><\/li>\n<\/ol>\n<hr>\n<h1 id=\"criteria\" class=\"heading\"><a href=\"#criteria\" class=\"heading-anchor\" aria-label=\"Permalink for Criteria\" tabindex=\"-1\"><\/a>Criteria<\/h1>\n<p>My ultimate end goal was to create something that kinda formed a hybrid between Twitch and Discord, both of which are\nimpressive in their own right. As such this let me pull up a wishlist of requirements to set myself in this process:<\/p>\n<ul>\n<li>Viewable online without installing anything<\/li>\n<li>No account required, although optionally available<\/li>\n<li>Simple text based chat<\/li>\n<li>Chat moderation<\/li>\n<li>Input access control<\/li>\n<li>Near realtime latency<\/li>\n<li>Good(enough) frame rate (>25fps will do)<\/li>\n<li>Good(enough) resolution (720p is fine for what I do)<\/li>\n<li>Transcoding<\/li>\n<li>Possibility of multiple streams simultaneously<\/li>\n<li>Minimum of on the wire encrypted with possibility of E2EE<\/li>\n<li>Ability to scale (hilariously ambitious)<\/li>\n<\/ul>\n<h1 id=\"existing-self-hosted-options-aka-lets-go-window-shopping\" class=\"heading\"><a href=\"#existing-self-hosted-options-aka-lets-go-window-shopping\" class=\"heading-anchor\" aria-label=\"Permalink for Existing self-hosted options aka lets go window shopping\" tabindex=\"-1\"><\/a>Existing self-hosted options <br><small>aka lets go window shopping<\/small><\/h1>\n<p>Whilst there are quite a few options out there already for doing this in the self-hosted space, all of them had one\nissue or another which I didn't like. Primarily this almost always boiled down to latency, realtime streaming is quite\nhard, especially with a reasonable quality.<\/p>\n<p>I'll briefly talk about each option first then I'll do a feature matrix to compare them all.<\/p>\n<h2 id=\"jitsi\" class=\"heading\"><a href=\"#jitsi\" class=\"heading-anchor\" aria-label=\"Permalink for Jitsi\" tabindex=\"-1\"><\/a>Jitsi<\/h2>\n<p>The very first platform I tried was one I was already familiar with, <a href=\"https:\/\/jitsi.org\/\">Jitsi<\/a>. I&#39;ll admit, I love\nJitsi and I already run my own Jitsi server so trying it out wasn&#39;t a problem, jump on a call, get a friend or two to\njoin, stream game. Results were almost immediate and somewhat as expected, good latency, poor quality\/framerate,\ndefinitely video call oriented.<\/p>\n<p>Whilst Jitsi is capable of having access controls on it, setting up Prosody to do this whilst maintaining the ability\nfor anybody to use it was a pain I didn't even venture into.<\/p>\n<h2 id=\"owncast\" class=\"heading\"><a href=\"#owncast\" class=\"heading-anchor\" aria-label=\"Permalink for Owncast\" tabindex=\"-1\"><\/a>Owncast<\/h2>\n<p>Next came <a href=\"https:\/\/owncast.online\/\">Owncast<\/a> which was also super easy to setup in Docker. Pull a few containers, mount\na few volumes, forward a few ports and add to my existing reverse proxy, job done.<\/p>\n<p>I actually ran this for a few months and did a few streams on it, overall I was quite impressed. Playing around with the\nsettings you could upload chunks to an S3 compatible service then stream through a CDN for near limitless scalability,\nalthough the chat was entirely ephemeral and even without proxying the files it still had a good 15s latency.<\/p>\n<h2 id=\"peertube\" class=\"heading\"><a href=\"#peertube\" class=\"heading-anchor\" aria-label=\"Permalink for Peertube\" tabindex=\"-1\"><\/a>Peertube<\/h2>\n<p><a href=\"https:\/\/joinpeertube.org\/\">Peertube<\/a> v3 brought <a href=\"https:\/\/joinpeertube.org\/news#release-3.0\">basic livestreaming<\/a>, and\nlater releases added chat, P2P video playing and is generally just awesome software. Unfortunately I almost immediately\nran into the same problem with latency that I did with Owncast, and it was super clunky to get a stream going. The chat\nwas also pretty poor, with next to no moderation facilities. It did have direct recording which was nice, but if I&#39;m\ngoing to record it I tend to do that locally anyway.<\/p>\n<p>One thing Peertube really had going for it than non of the others did was ActivityPub sharing of when you went live.\nViewers could subscribe to this and their home instance would notify them whenever I started streaming.<\/p>\n<p>As nice as Peertube is, and despite it still running after my experiments, I decided it wasn't for live streaming and\nrelegated it just to video sharing duty.<\/p>\n<h2 id=\"comparison\" class=\"heading\"><a href=\"#comparison\" class=\"heading-anchor\" aria-label=\"Permalink for Comparison\" tabindex=\"-1\"><\/a>Comparison<\/h2>\n<table>\n<thead>\n<tr>\n<th>\u00a0<\/th>\n<th>Jitsi<\/th>\n<th>Owncast<\/th>\n<th>Peertube<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Browser based<\/td>\n<td>\u2705<\/td>\n<td>\u2705<\/td>\n<td>\u2705<\/td>\n<\/tr>\n<tr>\n<td>Guest access<\/td>\n<td>\u2705<\/td>\n<td>\u2705<\/td>\n<td>\u2705<\/td>\n<\/tr>\n<tr>\n<td>Chat<\/td>\n<td>\u274c<\/td>\n<td>\u2705<\/td>\n<td>\u274c<\/td>\n<\/tr>\n<tr>\n<td>Moderation<\/td>\n<td>\u274c<\/td>\n<td>\u2705<\/td>\n<td>\u274c<\/td>\n<\/tr>\n<tr>\n<td>Access control<\/td>\n<td>\u274c<\/td>\n<td>\u2705<\/td>\n<td>\u2705<\/td>\n<\/tr>\n<tr>\n<td>Latency<\/td>\n<td>\u2705<\/td>\n<td>\u274c<\/td>\n<td>\u274c<\/td>\n<\/tr>\n<tr>\n<td>Framerate<\/td>\n<td>\u274c<\/td>\n<td>\u2705<\/td>\n<td>\u2705<\/td>\n<\/tr>\n<tr>\n<td>Resolution<\/td>\n<td>\u274c<\/td>\n<td>\u2705<\/td>\n<td>\u2705<\/td>\n<\/tr>\n<tr>\n<td>Transcoding<\/td>\n<td>\u274c<\/td>\n<td>\u2705<\/td>\n<td>\u2705<\/td>\n<\/tr>\n<tr>\n<td>Multiple streams<\/td>\n<td>\u2705<\/td>\n<td>\u274c<\/td>\n<td>\u2705<\/td>\n<\/tr>\n<tr>\n<td>Encryption<\/td>\n<td>\u2705<br>(E2EE)<\/td>\n<td>\u2705<\/td>\n<td>\u2705<\/td>\n<\/tr>\n<tr>\n<td>Scalable<\/td>\n<td>\u2705<br>with difficulty<\/td>\n<td>\u2705<\/td>\n<td>\u274c<\/td>\n<\/tr>\n<tr>\n<td>{: .feature-matrix }<\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h1 id=\"part-2\" class=\"heading\"><a href=\"#part-2\" class=\"heading-anchor\" aria-label=\"Permalink for Part 2\" tabindex=\"-1\"><\/a>Part 2<\/h1>\n<p>Next up in part 2 we&#39;ll look at some <a href=\"\/2022\/live-itsg-host-part-2\" class=\"\">new technologies<\/a> used to build Ghost Live.<\/p>","url":"https:\/\/itsg.host\/2022\/live-itsg-host-part-1","title":"Ghost Live! (part 1: current solutions)","date_modified":"2022-04-11T00:00:00.000Z","tags":[]},{"content_html":"<p>Building livestreaming and chat services is hard, thankfully some very kind people have already done most of the legwork.<\/p>\n<p>In part 1 we looked at some <a href=\"\/2022\/live-itsg-host-part-1\" class=\"\">existing solutions<\/a>, and the problems they pose.\nIn this part we look at some of these services in a bit more detail to work out what they are good at, and what challenges we will need to overcome.<\/p>\n<hr>\n<p>This is part two of a three part series:<\/p>\n<ol>\n<li><a href=\"\/2022\/live-itsg-host-part-1\" class=\"\">Current solutions<\/a><\/li>\n<li><a href=\"\/2022\/live-itsg-host-part-2\" class=\"\">New technologies<\/a><\/li>\n<li><a href=\"\/2022\/live-itsg-host-part-3\" class=\"\">Building your own streaming service<\/a><\/li>\n<\/ol>\n<hr>\n<h1 id=\"ovenmediaengine\" class=\"heading\"><a href=\"#ovenmediaengine\" class=\"heading-anchor\" aria-label=\"Permalink for OvenMediaEngine\" tabindex=\"-1\"><\/a>OvenMediaEngine<\/h1>\n<p>In this course of doing all the research trialing the above, I stumbled across <a href=\"https:\/\/www.ovenmediaengine.com\/ome\">OvenMediaEngine<\/a>.\nBy itself it doesn&#39;t do much, it focuses purely on the ingestion of a source and sending that to multiple outputs.\nHowever, as a foundation it seems to have all the requirements for the video streaming side of things.<\/p>\n<table>\n<thead>\n<tr>\n<th><\/th>\n<th><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Browser based<\/td>\n<td>\u2705<\/td>\n<\/tr>\n<tr>\n<td>Guest access<\/td>\n<td>\u2705<\/td>\n<\/tr>\n<tr>\n<td>Access control<\/td>\n<td>\u2705<\/td>\n<\/tr>\n<tr>\n<td>Latency<\/td>\n<td>\u2705<\/td>\n<\/tr>\n<tr>\n<td>Framerate<\/td>\n<td>\u2705<\/td>\n<\/tr>\n<tr>\n<td>Resolution<\/td>\n<td>\u2705<\/td>\n<\/tr>\n<tr>\n<td>Transcoding<\/td>\n<td>\u2705<\/td>\n<\/tr>\n<tr>\n<td>Multiple streams<\/td>\n<td>\u2705<\/td>\n<\/tr>\n<tr>\n<td>Encryption<\/td>\n<td>\u2705<\/td>\n<\/tr>\n<tr>\n<td>Scalable<\/td>\n<td>\u2705<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Essentially all that was missing was a chat system, but given it didn't come with a ready-made interface, that would be a problem for me to solve anyway.<\/p>\n<h2 id=\"ingestion\" class=\"heading\"><a href=\"#ingestion\" class=\"heading-anchor\" aria-label=\"Permalink for Ingestion\" tabindex=\"-1\"><\/a>Ingestion<\/h2>\n<p>OME out of the box supports several ingestion protocols, including:<\/p>\n<ul>\n<li>RTMP(S)<\/li>\n<li>SRT<\/li>\n<li>WebRTC<\/li>\n<li>MPEG-2 TS<\/li>\n<li>RTSP<\/li>\n<\/ul>\n<p>For this use case I'll be using RTMPS as it's the most widely supported.\nTLS termination can be done by either OME itself or by a reverse proxy in-front if you want to support use LetsEncrypt.<\/p>\n<h2 id=\"output\" class=\"heading\"><a href=\"#output\" class=\"heading-anchor\" aria-label=\"Permalink for Output\" tabindex=\"-1\"><\/a>Output<\/h2>\n<p>In order to reliably stream to different devices, you unfortunately need to support several protocols, because people can't agree on which one to use.<\/p>\n<p>By far the most important here for low latency is WebRTC, the protocol used for video calls.\nIt offers near realtime latency with only a minimal delay for transcoding where needed.\nThis works on most devices, but relies on a few non-standard ports and often needs ICE to perform firewall punching in order to establish a connection.\nOME also currently has experimental support for P2P distribution via WebRTC, although this already includes direct fallback in the event a peer cannot establish a connection.<\/p>\n<p>In order to support a full array of devices though, HLS and MPEG-DASH are also required.\nThese are buffered protocols that split the stream into multiple short chunks (usually 5 seconds), and publish an updating playlist telling clients where they can find the next chunk.\nClients will usually buffer a few chunks ahead of what is displayed so there aren't interruptions if there is a delay in fetching the next chunk.\nObviously all this buffering server and client side leads to quite a noticeable delay in the stream, often around a minute or more.<\/p>\n<h2 id=\"transcoding\" class=\"heading\"><a href=\"#transcoding\" class=\"heading-anchor\" aria-label=\"Permalink for Transcoding\" tabindex=\"-1\"><\/a>Transcoding<\/h2>\n<p>In order to work smoothly on different internet connections, most streaming services offer multiple resolutions and frame rates.\nThis ensures that clients can select a quality that is appropriate for their network connection and hardware capabilities, downgrading to a lower quality if either one is a bottleneck.\nDifferent output methods also need different encoding, something generally not provided by most sources.<\/p>\n<p>OME supports this by transcoding all input streams into every required output stream format\/codec as soon as it is ingested.\nThe number of qualities here is something to watch, as this is very heavy on both server CPU and memory.\nGPU acceleration is supported, but I haven't experimented with this at this time.<\/p>\n<h2 id=\"ovenmediaplayer\" class=\"heading\"><a href=\"#ovenmediaplayer\" class=\"heading-anchor\" aria-label=\"Permalink for OvenMediaPlayer\" tabindex=\"-1\"><\/a>OvenMediaPlayer<\/h2>\n<p>To go with OME, OMP provides a ready to use player library that supports all the features of OME.\nIt comes with cross-platform support, and all the required signaling for WebRTC video streaming.<\/p>\n<h1 id=\"matrix\" class=\"heading\"><a href=\"#matrix\" class=\"heading-anchor\" aria-label=\"Permalink for Matrix\" tabindex=\"-1\"><\/a>Matrix<\/h1>\n<p>If you look into the self-hosted chat world for long, you&#39;ll come across <a href=\"https:\/\/matrix.org\">matrix<\/a>.\nMatrix is a federated chat protocol based on JSON over HTTPS, and supports multiple media types including images, stickers, and VOIP.\nQuite importantly, matrix itself does not specify exactly what software you need to use.\nWhilst there are reference implementations, it is just a formal protocol for clients and servers to follow.<\/p>\n<h2 id=\"homeserver\" class=\"heading\"><a href=\"#homeserver\" class=\"heading-anchor\" aria-label=\"Permalink for Homeserver\" tabindex=\"-1\"><\/a>Homeserver<\/h2>\n<p>Each client in matrix talks to a primary homesever.\nThere are several options to choose from here, all written differently depending on the use case.\nWhilst the spec does say which features need to be supported, it's a bit hit and miss if a server actually provides those features, let alone enables them.\nIn order for this all to work, the homserver needs to support appservices and guest access.<\/p>\n<h3 id=\"guest-access\" class=\"heading\"><a href=\"#guest-access\" class=\"heading-anchor\" aria-label=\"Permalink for Guest access\" tabindex=\"-1\"><\/a>Guest access<\/h3>\n<p>Guest access to matrix, whilst <a href=\"https:\/\/spec.matrix.org\/v1.2\/client-server-api\/#guest-access\">officially supported by the protocol<\/a>, has very intermittent support.\nThe official reference client, <a href=\"https:\/\/element.io\/\">element<\/a>, can be very finicky with when it decides to grant guest access, and when it will allow a guest to post to a room.\nThis likely means we will need to use a different client for our system.<\/p>\n<h2 id=\"cactus\" class=\"heading\"><a href=\"#cactus\" class=\"heading-anchor\" aria-label=\"Permalink for Cactus\" tabindex=\"-1\"><\/a>Cactus<\/h2>\n<p><a href=\"https:\/\/cactus.chat\/\">Cactus Comments<\/a> is a small service built ontop of the matrix protocol, infact it&#39;s even on this page!\nIt has an appservice to manage the chat rooms, and a very basic client to create a guest account and interact with the chat room.\nDue to its compatibility, we can interact with the stream chat from any matrix client.\nThanks to the appservice, the owner of the stream can have moderation rights to the room and can therefore moderate the chat as appropriate.\nUnfortunately due to its open nature, banning a user from the chat is a bit more difficult.<\/p>\n<h1 id=\"part-3\" class=\"heading\"><a href=\"#part-3\" class=\"heading-anchor\" aria-label=\"Permalink for Part 3\" tabindex=\"-1\"><\/a>Part 3<\/h1>\n<p>Now we know a bit more about the technologies involved, it&#39;s time to start looking into how we can tie these all together and <a href=\"\/2022\/live-itsg-host-part-3\" class=\"\">create our own streaming system<\/a>.<\/p>","url":"https:\/\/itsg.host\/2022\/live-itsg-host-part-2","title":"Ghost Live! (part 2: new technologies)","date_modified":"2022-04-11T00:00:00.000Z","tags":[]},{"content_html":"<p>So, now we&#39;ve looked at <a href=\"\/2022\/live-itsg-host-part-1\" class=\"\">existing solutions<\/a> and some <a href=\"\/2022\/live-itsg-host-part-2\" class=\"\">new technologies<\/a>, it&#39;s time we thought about actually building our own.<\/p>\n<hr>\n<p>This is part three of a three part series:<\/p>\n<ol>\n<li><a href=\"\/2022\/live-itsg-host-part-1\" class=\"\">Current solutions<\/a><\/li>\n<li><a href=\"\/2022\/live-itsg-host-part-2\" class=\"\">New technologies<\/a><\/li>\n<li><a href=\"\/2022\/live-itsg-host-part-3\" class=\"\">Building your own streaming service<\/a><\/li>\n<\/ol>\n<hr>\n<p>This part is going to get <strong>very<\/strong> technical, and is going to assume quite a bit of prior knowledge, including both ops and Javascript programming.\nIt's the reason this is split up into multiple parts to make things easier to understand how it works to the not so technically inclined.<\/p>\n<p>I won't be including exact examples here, there's too many specifics to each deployment.<\/p>\n<h1 id=\"prerequisites\" class=\"heading\"><a href=\"#prerequisites\" class=\"heading-anchor\" aria-label=\"Permalink for Prerequisites\" tabindex=\"-1\"><\/a>Prerequisites<\/h1>\n<p>This isn't a comprehensive guide on how to do everything, you'll need to have a few things setup already for which there are plenty of tutorials out there that I couldn't hope to write.\nTo start with you'll definitely need:<\/p>\n<ul>\n<li>Domain name<\/li>\n<li>Publicly routable IP<\/li>\n<li>Reasonably powerful server<\/li>\n<li>Fast upload speed<\/li>\n<li>A knowledge of port forwarding<\/li>\n<li>Matrix homeserver with appservice support<\/li>\n<\/ul>\n<p>Although entirely possible to do without, the following will definitely help you:<\/p>\n<ul>\n<li>Docker<\/li>\n<li>Static public IP (could be done with dynamic DNS, but that's outside the scope of this)<\/li>\n<li>Reverse proxy (I'll be using traefik, but this also works with nginx)<\/li>\n<li>Knowledge of\n<ul>\n<li>TLS<\/li>\n<li>WebRTC<\/li>\n<li>UDP streams<\/li>\n<li>VueJS\/Typescript<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h1 id=\"ovenmediaengine\" class=\"heading\"><a href=\"#ovenmediaengine\" class=\"heading-anchor\" aria-label=\"Permalink for OvenMediaEngine\" tabindex=\"-1\"><\/a>OvenMediaEngine<\/h1>\n<p>First thing you&#39;ll need to get spun up is your OME server.\nThe <a href=\"https:\/\/airensoft.gitbook.io\/ovenmediaengine\/getting-started\">getting started guide<\/a> here is very good and will talk you through the process for both a docker install and a manual installation.<\/p>\n<p>If using docker, make sure to mount <code>\/opt\/ovenmediaengine\/bin\/origin_conf<\/code> to a local directory, so you can manage the config directly.\nYou may need to copy the base <code>Server.xml<\/code> out of the container first. I leave this as an exercise ot the reader.<\/p>\n<p>The config is mostly self-explanatory, read through it and look for anything that needs changing from its defaults.\nIn my case I needed to update the <code>IceCandidates<\/code> section to use my own coturn instance.\nThe following tags are ones to pay attention to:<\/p>\n<ul>\n<li><code>Profiles<\/code><\/li>\n<li><code>Publishers<\/code><\/li>\n<\/ul>\n<h2 id=\"stream-security\" class=\"heading\"><a href=\"#stream-security\" class=\"heading-anchor\" aria-label=\"Permalink for Stream security\" tabindex=\"-1\"><\/a>Stream security<\/h2>\n<p>Under the <code>VirtualHost<\/code> tag you can configure OME to only accept streams with a signed stream key.\nThe OME docs have a good explanation of the <a href=\"https:\/\/airensoft.gitbook.io\/ovenmediaengine\/access-control\/signedpolicy\">signed policy<\/a>.<\/p>\n<p>The redacted policy I use is below. This only requires a signature to push a stream, it allows anybody to view:<\/p>\n<pre><code class=\"language-xml\">&#x3C;SignedPolicy>\n    &#x3C;PolicyQueryKeyName>p&#x3C;\/PolicyQueryKeyName>\n    &#x3C;SignatureQueryKeyName>s&#x3C;\/SignatureQueryKeyName>\n    &#x3C;SecretKey>MySuperSecretSigningKey&#x3C;\/SecretKey>\n\n    &#x3C;Enables>\n        &#x3C;Providers>rtmp,webrtc,srt&#x3C;\/Providers>\n        &#x3C;!-- &#x3C;Publishers>webrtc,hls,dash,lldash&#x3C;\/Publishers> -->\n    &#x3C;\/Enables>\n&#x3C;\/SignedPolicy>\n<\/code><\/pre>\n<h2 id=\"port-forwardingrouting\" class=\"heading\"><a href=\"#port-forwardingrouting\" class=\"heading-anchor\" aria-label=\"Permalink for Port forwarding\/routing\" tabindex=\"-1\"><\/a>Port forwarding\/routing<\/h2>\n<p>OME requires a lot of ports forwarding, how you do this will depend on your deployment.\nI have a split deployment with some ports going direct from my public IP, and others getting routed via traefik (mainly for TLS termination with LetsEncrypt).<\/p>\n<p>For my traefik deployment, I run the following config to route everything correctly over HTTPS. The DNS name <code>ovenmediaengine<\/code> resolves to the container running OME.<\/p>\n<pre><code class=\"language-yaml\">http:\n  routers:\n    stream-origin:\n      entryPoints:\n        - https\n      rule: Host(`stream.itsg.host`)\n      service: ovenmediaengine-origin\n      middlewares:\n        - ovenmediaengine\n\n    stream-media:\n      entryPoints:\n        - https\n      rule: Host(`stream.itsg.host`) &#x26;&#x26; (Path(`\/time`) || Path(`\/live\/{file:.+\/.+\\..{2,5}}`))\n      service: ovenmediaengine-media\n      middlewares:\n        - ovenmediaengine\n\n    stream-signal:\n      entryPoints:\n        - https\n      rule: Host(`stream.itsg.host`) &#x26;&#x26; Path(`\/live\/{stream:.+}`)\n      service: ovenmediaengine-signal\n      middlewares:\n        - ovenmediaengine\n\n  services:\n    ovenmediaengine-origin:\n      loadBalancer:\n        servers:\n          - url: http:\/\/ovenmediaengine:9000\/\n    ovenmediaengine-media:\n      loadBalancer:\n        servers:\n          - url: http:\/\/ovenmediaengine:8080\/\n    ovenmediaengine-signal:\n      loadBalancer:\n        servers:\n          - url: http:\/\/ovenmediaengine:3333\/\n\n  middlewares:\n    ovenmediaengine:\n      headers:\n        accessControlAllowMethods:\n          - GET\n          - OPTIONS\n          - PUT\n        accessControlAllowOriginList: '*'\n        accessControlMaxAge: 100\n        addVaryHeader: true\n\ntcp:\n  routers:\n    ovenmediaengine-rtmp:\n      entryPoints:\n        - rtmp\n      rule: \"HostSNI(`*`)\"\n      service: ovenmediaengine-rtmp\n\n    ovenmediaengine-rtmps:\n      entryPoints:\n        - rtmp\n        - https\n      rule: \"HostSNI(`stream.itsg.host`)\"\n      service: ovenmediaengine-rtmp\n      tls: true\n\n    ovenmediaengine-turn:\n      entryPoints:\n        - stream-turn\n      rule: \"HostSNI(`*`)\"\n      service: ovenmediaengine-turn\n\n  services:\n    ovenmediaengine-rtmp:\n      loadBalancer:\n        servers:\n          - address: ovenmediaengine:1935\n\n    ovenmediaengine-turn:\n      loadBalancer:\n        servers:\n          - address: ovenmediaengine:3748\n<\/code><\/pre>\n<p>All other ports, especially WebRTC media ports, are forwarded directly from my perimeter firewall.<\/p>\n<h1 id=\"cactus\" class=\"heading\"><a href=\"#cactus\" class=\"heading-anchor\" aria-label=\"Permalink for Cactus\" tabindex=\"-1\"><\/a>Cactus<\/h1>\n<p>Setting up Cactus is pretty straight forward, it works just like any other matrix appservice.\nThere is a hosted version contactable at <a href=\"https:\/\/matrix.to\/#\/@cactusbot:cactus.chat\">@cactusbot:cactus.chat<\/a>, but I prefer to run my own version of it on my own homeserver.\nThe <a href=\"https:\/\/cactus.chat\/docs\/server\/self-host\/\">self hosting<\/a> guide gives a good explanation of how to do this, and of course this can be done using docker.<\/p>\n<p>Whichever you choose, you&#39;ll want to follow the <a href=\"https:\/\/cactus.chat\/docs\/getting-started\/quick-start\/\">quick start<\/a> to get a chat room up and going.<\/p>\n<h1 id=\"building-a-frontend\" class=\"heading\"><a href=\"#building-a-frontend\" class=\"heading-anchor\" aria-label=\"Permalink for Building a frontend\" tabindex=\"-1\"><\/a>Building a frontend<\/h1>\n<p>Now all the components are together, it&#39;s time to tie it all together with a frontend.\nI had to build my own, and did so using Vue, it&#39;s available in the <a href=\"https:\/\/gitlab.com\/ItsGhost\/live.itsg.host\">live.itsg.host GitLab<\/a><\/p>\n<p>I encourage anyone whose made it this far to build their own, you're welcome to fork mine but it's a real learning experience.\nTo help with this, here's the key parts of how my UI works.<\/p>\n<h2 id=\"stream-name\" class=\"heading\"><a href=\"#stream-name\" class=\"heading-anchor\" aria-label=\"Permalink for Stream name\" tabindex=\"-1\"><\/a>Stream name<\/h2>\n<p>The name of the stream you wish to view is simply pulled from the URL by the Vue <a href=\"https:\/\/gitlab.com\/ItsGhost\/live.itsg.host\/-\/blob\/eddbdc4b32cce897df3c87885438e1bf85a01e01\/src\/router\/index.ts\">router<\/a>.\nThe value from this is passed to the top level component of each view.<\/p>\n<h2 id=\"determining-live-status\" class=\"heading\"><a href=\"#determining-live-status\" class=\"heading-anchor\" aria-label=\"Permalink for Determining live status\" tabindex=\"-1\"><\/a>Determining live status<\/h2>\n<p>When the Vue app loads, it dispatches a <a href=\"https:\/\/gitlab.com\/ItsGhost\/live.itsg.host\/-\/blob\/eddbdc4b32cce897df3c87885438e1bf85a01e01\/src\/store\/index.ts#L52\">periodic job to check OME to see if a stream is currently live<\/a>.\nThis is relatively easy to do, with HLS enabled OME will create a file at <code>&#x3C;OME app>\/&#x3C;stream name>\/playlist.m3u8<\/code> if the stream is live.\nIf this file exists, then the stream is live and the player can attempt to start it, if it 404s then the player should display an offline message.<\/p>\n<h2 id=\"embedding-cactus\" class=\"heading\"><a href=\"#embedding-cactus\" class=\"heading-anchor\" aria-label=\"Permalink for Embedding cactus\" tabindex=\"-1\"><\/a>Embedding cactus<\/h2>\n<p><a href=\"https:\/\/gitlab.com\/ItsGhost\/live.itsg.host\/-\/blob\/eddbdc4b32cce897df3c87885438e1bf85a01e01\/src\/components\/CactusChat.vue\">CactusChat.vue<\/a> creates an instance of cactus chat based on the stream name from the URL.\nIt requires a bit of configuring and required a post load in Vue to lack of a npm package at the time of writing.<\/p>\n<p>Upon loading, cactus will automatically register a guest account (persisted to localstorage) and fetch the state of the chat room for the stream name.\nThis allows chatting even when the stream is offline, and persists all chat on the matrix homeserver.<\/p>\n<p>Unfortunately at this time cactus does not support sending images or stickers, the latter being a special case in matrix anyway.<\/p>\n<h2 id=\"fetching-stream-title\" class=\"heading\"><a href=\"#fetching-stream-title\" class=\"heading-anchor\" aria-label=\"Permalink for Fetching stream title\" tabindex=\"-1\"><\/a>Fetching stream title<\/h2>\n<p>One of the parts I&#39;m most proud of is the UI&#39;s ability to <a href=\"https:\/\/gitlab.com\/ItsGhost\/live.itsg.host\/-\/blob\/eddbdc4b32cce897df3c87885438e1bf85a01e01\/src\/store\/index.ts#L34\">fetch a stream title<\/a> from the chat room title in matrix.\nThis makes the UI dynamic whilst also just running on static hosting.<\/p>\n<p>Doing this was a tad complicated because of how matrix does things, but it essentially requires fetching the public room directory of the home server and searching through it to find one that matches the expected room name from cactus.\nThankfully the expected room name is very predictable, most of it is statically configured in cactus, it just needs to inject the stream name variable from the URL.<\/p>\n<p>This is in-fact the same technique the cactus uses to load the room state, only we extract the <code>name<\/code> variable instead.<\/p>\n<h2 id=\"embedding-stream\" class=\"heading\"><a href=\"#embedding-stream\" class=\"heading-anchor\" aria-label=\"Permalink for Embedding stream\" tabindex=\"-1\"><\/a>Embedding stream<\/h2>\n<p>To give that full discord like experience, the stream player is embeddable within a matrix client using an integration manager.\nFor this I use <a href=\"https:\/\/dimension.t2bot.io\/\">dimension<\/a> but that is outside the scope of this guide.<\/p>\n<p>The embed URL follows the same logic as all the others, except it doesn&#39;t include the stream title or chat window, and is simply the player full width or height on an empty background.\nIn order for it to be embeddable, CORS rules need to be setup to allow this with your hosting provider.\nBeing a static site, I run mine on CloudFlare pages so the <a href=\"https:\/\/gitlab.com\/ItsGhost\/live.itsg.host\/-\/blob\/eddbdc4b32cce897df3c87885438e1bf85a01e01\/public\/_headers\">_headers<\/a> file achieves this.\nThe process would be similar for Netlify or other static site hosting.<\/p>\n<h1 id=\"conclusion\" class=\"heading\"><a href=\"#conclusion\" class=\"heading-anchor\" aria-label=\"Permalink for Conclusion\" tabindex=\"-1\"><\/a>Conclusion<\/h1>\n<p>Well, I think I've waffled on enough now, lets see how my finished streaming service lines up with my initial requirements criteria:<\/p>\n<table>\n<thead>\n<tr>\n<th><\/th>\n<th><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Browser based<\/td>\n<td>\u2705<br>With native option<\/td>\n<\/tr>\n<tr>\n<td>Guest access<\/td>\n<td>\u2705<\/td>\n<\/tr>\n<tr>\n<td>Chat<\/td>\n<td>\u2705<\/td>\n<\/tr>\n<tr>\n<td>Moderation<\/td>\n<td>\u2705<\/td>\n<\/tr>\n<tr>\n<td>Access control<\/td>\n<td>\u2705<br>Signed stream key<\/td>\n<\/tr>\n<tr>\n<td>Latency<\/td>\n<td>\u2705<\/td>\n<\/tr>\n<tr>\n<td>Framerate<\/td>\n<td>\u2705<\/td>\n<\/tr>\n<tr>\n<td>Resolution<\/td>\n<td>\u2705<\/td>\n<\/tr>\n<tr>\n<td>Transcoding<\/td>\n<td>\u2705<\/td>\n<\/tr>\n<tr>\n<td>Multiple streams<\/td>\n<td>\u2705<br>With dynamic title<\/td>\n<\/tr>\n<tr>\n<td>Encryption<\/td>\n<td>\u2705<br> WebRTC\/TLS<\/td>\n<\/tr>\n<tr>\n<td>Scalable<\/td>\n<td>\u2705<br>OME edge replica<\/td>\n<\/tr>\n<tr>\n<td>{: .feature-matrix }<\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>I'd call that a success.<\/p>\n<p>There's certainly still room for improvement, ActivityPub would be nice for subscriptions, although users can register with matrix and join natively to be notified by <code>@room<\/code> messages.\nFor now though, I'm more than happy with it, and the server load appears to scale very slowly after the initial viewer (first transcode is the most intensive).<\/p>\n<p>If you do decide to take this on yourself, I'd welcome pull requests to improve the core logic of the UI.\nIf you have any questions, pop them in the comments below, I'll get a ping on matrix just as I do when streaming ;)<\/p>","url":"https:\/\/itsg.host\/2022\/live-itsg-host-part-3","title":"Ghost Live! (part 3: building your own streaming service)","date_modified":"2022-04-11T00:00:00.000Z","tags":[]},{"content_html":"<p>Two or three ago a friend asked me which domain registrar I was using for things these days, and it sparked some discourse around the use of CloudFlare especially with self-hosting.\nNow this is a topic I've given considerably thought to over the years, but never actually put into one place concisely.\nThis is an omission I wish to correct here.<\/p>\n<p>The crux of the argument essentially boiled down to if CloudFlare was a \"good\" company, and if what they had to offer was of any benefit to an open and decentralised internet.\nUnfortunately, a lot of what can be said on the matter comes from almost pure speculation, and in many cases there is very by way of evidence that could be provided.\nA lot of the technical arguments also only look at individual cases, which is how it should be, but miss the bigger picture.\nAs such, I'm going to attempt to argue around the concepts rather than the implementation itself.<\/p>\n<p>I want to warn all readers; this is a VERY heavily opinionated technical piece combining a decade of both personal and professional hosting experience with personal beliefs and morals.\nI do not expect everyone to agree with me, and this is a good thing, I want people to form their own opinions and draw their own conclusions.<\/p>\n<h2 id=\"cloudflare-dns\" class=\"heading\"><a href=\"#cloudflare-dns\" class=\"heading-anchor\" aria-label=\"Permalink for CloudFlare DNS\" tabindex=\"-1\"><\/a>CloudFlare DNS<\/h2>\n<p>DNS itself is often a very controversial topic, not helped by the existence of <a href=\"https:\/\/en.wikipedia.org\/w\/index.php?title=Five_Eyes&amp;oldid=1173906976\">Five Eyes<\/a> and its relatives, although I shall attempt to avoid going down this particular tin foil hat wearing rabbit hole.\nTo avoid this turning into several volumes, for those who are unfamiliar, I&#39;ll let CloudFlare themselves explain <a href=\"https:\/\/www.cloudflare.com\/en-gb\/learning\/dns\/what-is-dns\/\">what is DNS<\/a>.<\/p>\n<h3 id=\"dns-hosting\" class=\"heading\"><a href=\"#dns-hosting\" class=\"heading-anchor\" aria-label=\"Permalink for DNS Hosting\" tabindex=\"-1\"><\/a>DNS Hosting<\/h3>\n<p>The most basic service CloudFlare offers is DNS hosting, they provide a very capable tier of it for free.\nUpon registering, you get given some values for NS &#39;glue records&#39; to pass onto your <a href=\"#dns-registrar\">registrar<\/a>, which tells the global internet where to send its queries for your domain, and you&#39;re done.\nDNS hosting is so core to what CloudFlare does, almost everything else they offer is dependant upon it.\nThe only true DNS upgrade available is custom nameservers for business customers, which even then is only something if you are super paranoid about brand identity at a technical level<\/p>\n<p>Let us imagine that CloudFlare wanted to host your DNS in bad faith, what potential attacks are available to them.\nAs far as I am aware, there are only two major ones; serving bad responses, and logging what requests are made.\nI consider the former so easy to detect that no sane company is going to risk their entire reputation on it for minimal gain, and the latter a non-issue if end users are using properly configured resolvers.\nBoth of these arguments are also undermined by basic DNS being entirely unprotected, anybody along the path of the request could modify or log it.\nWhilst they are certainly not alone, as this is also offered by most reputable DNS providers, CloudFlare do offer a range of functions for <a href=\"https:\/\/www.cloudflare.com\/en-gb\/learning\/dns\/dns-security\/\">securing DNS<\/a>.<\/p>\n<h3 id=\"dns-registrar\" class=\"heading\"><a href=\"#dns-registrar\" class=\"heading-anchor\" aria-label=\"Permalink for DNS Registrar\" tabindex=\"-1\"><\/a>DNS Registrar<\/h3>\n<p>The other half of DNS you need to be aware of in any hosting is DNS registration, done through a registrar.\nYour registrar acts as custodian for your domain, telling the top level domain servers where to send people looking for your domain.\nThey are also the ones who take your money for this privilege, and who are responsible for collecting and validating the information they are legally required to store.<\/p>\n<aside><p>I've been made aware of some registrars who do not require any personal information when buying a domain, usually done\nthrough cryptocurrency as well.\nWhilst this is great for anonymity, they then own the domain on your behalf and can arbitarily decide to deny you\naccess to it.\nUsing a reputable registrar ensures that you legally own the domain under the terms of the TLD registrar for that\ndomain, access can only be fully revoked by them.\nThis might be something you have to challenge legally if it came to it, but better to have that defence than not.<\/p><\/aside>\n<p>This gives them a few important powers, making profit of you directly, or from the personal information you have to provide, and response poisoning as with DNS Hosting.\nRather unusually in the registrar world, CloudFlare offer their registrations <a href=\"https:\/\/www.cloudflare.com\/en-gb\/learning\/dns\/what-is-cloudflare-registrar\/\">at cost<\/a>, as well as providing DNSSEC and WHOIS privacy as standard, the latter of which some registrars attempt to charge extra for.\nRegarding abuse of information, I would have to provide this to any registrar, and with the exception of an email address and phone number, is public information anyway (at least in the UK).\nI personally cannot see what value they could gain from selling this information given the only thing it will accurately correlate with is the domain registration itself.<\/p>\n<p>As for response poisoning, I can't see anyway in which this would be advantageous for any reputable service for anything more than a few minutes before its easily detected, after which their reputation and trust would be worthless, making it effectively a one shot attack.<\/p>\n<h2 id=\"cloudflare-services\" class=\"heading\"><a href=\"#cloudflare-services\" class=\"heading-anchor\" aria-label=\"Permalink for CloudFlare services\" tabindex=\"-1\"><\/a>CloudFlare services<\/h2>\n<p>I'm going to group together a large bunch of things here which all effectively boil down to the same talking points, all resulting from CloudFlare having access to the <em>unencrypted data<\/em>.\nUnlike with the DNS points above, there are many more attack vectors which is the interesting bit rather than the services themselves.\nFor those who are interested, I've included the following in this summation:<\/p>\n<ul>\n<li>Proxy<\/li>\n<li>Tunnel (<code>cloudflared<\/code>)<\/li>\n<li>Access<\/li>\n<li>Workers<\/li>\n<li>Pages<\/li>\n<\/ul>\n<p>Other services like Images, Streams, KV etc. also have many of the similar considerations, but I do not have first-hand experience with them, so my arguments may not be as applicable.<\/p>\n<h3 id=\"gatekeeper-of-the-internet\" class=\"heading\"><a href=\"#gatekeeper-of-the-internet\" class=\"heading-anchor\" aria-label=\"Permalink for Gatekeeper of the internet\" tabindex=\"-1\"><\/a>Gatekeeper of the internet<\/h3>\n<p>Imagine this, every website turns on CloudFlare protection.\nApart from the monumental amount of data transit that'd suddenly be required of them, that would give CloudFlare the ability to decide who gets to access what.<\/p>\n<p><strong>This would unequivocally be a complete disaster.<\/strong><\/p>\n<p>The internet works because it is computers talking to each other via multiple routes, if one is down, another can take its place.\nThere isn't any way in which giving a single entity that level of power ends well for the internet as a whole.<\/p>\n<p>This isn&#39;t entirely hypothetical either, try browsing normally using <a href=\"https:\/\/www.torproject.org\/\">Tor<\/a> and see how many sites just outright do not work.\nHistorically CloudFlare just outright blocked almost all of Tor, and unless your exit node was very new, you&#39;d get hit with an unpassable challenge page.\nTo take our first scenario again, suddenly Tor just ceases to work.<\/p>\n<p>These days CloudFlare are much more accepting of Tor and use a sensible (in my opinion) risk-based approach, and are supporting it insofar as to provide <a href=\"https:\/\/developers.cloudflare.com\/support\/firewall\/learn-more\/understanding-cloudflare-tor-support-and-onion-routing\/#onion-routing\">Tor Onion Routing as standard<\/a>.\nStill, the number of sites that are inaccessible because of a CloudFlare challenge, be that over Tor or with JavaScript disabled, is not insignificant.<\/p>\n<p>Many online argue that their current market share already gives CloudFlare too much power in centralising the internet, including myself on occasion.\nThis is certainly a massive trade-off you have to consider when opting to enable these services.\nWith how things are at the time of writing, I consider this an acceptable trade-off for the security and speed benefits that come from this approach.<\/p>\n<h3 id=\"mitm-yourself\" class=\"heading\"><a href=\"#mitm-yourself\" class=\"heading-anchor\" aria-label=\"Permalink for MITM Yourself\" tabindex=\"-1\"><\/a><abbr title=\"Man In The Middle\">MITM<\/abbr> Yourself<\/h3>\n<p>One of CloudFlare's main selling points is their CDN and DDoS protection, often referred to \"turning on the orange cloud\".\nEffectively at this point, all the data going over the wire is visible to CloudFlare; usernames, passwords, bank details, everything.\nGenerally, this is known as a MITM attack.\nThey are free to log, analyse, modify, and manipulate anything they like here, and as an end user it is next to impossible to detect this is happening.<\/p>\n<p>Worse still, with such specific access, they are able to do it only if a specific set of criteria are met.\nPerhaps they are only interested in compromising a single user, or are looking to link the same person from site to site.<\/p>\n<h4 id=\"you-are-not-special\" class=\"heading\"><a href=\"#you-are-not-special\" class=\"heading-anchor\" aria-label=\"Permalink for You are not special\" tabindex=\"-1\"><\/a>You are not special<\/h4>\n<p>To put it bluntly, ask yourself why CloudFlare would want to snoop on you or your users.\nWhat makes you so special that CloudFlare are going to risk their reputation for handling very sensitive plain text data (PCI or HIPPA compliance for example).\nQuite simply, I don't think anything I traverse over there is worthy of that, your threat model may vary.<\/p>\n<h4 id=\"application-layer-security\" class=\"heading\"><a href=\"#application-layer-security\" class=\"heading-anchor\" aria-label=\"Permalink for Application layer security\" tabindex=\"-1\"><\/a>Application layer security<\/h4>\n<p>The best way to ensure that CloudFlare proxying is a non-issue is to provide security at an application layer with <abbr title=\"End to End Encryption\">E2EE<\/abbr>\nBy way of example, I have CloudFlare services enabled on my Matrix homeserver.\nThis gives me the best of both worlds, the server is protected from bad actors and DDoS attacks (which are crippling for the inefficient Synapse server).\nWith E2EE enabled, CloudFlare only has access to some basic client to server or server to server metadata, the message content and a good chunk of metadata is protected by the Matrix protocol itself.<\/p>\n<h3 id=\"discrimination-can-be-a-good-thing\" class=\"heading\"><a href=\"#discrimination-can-be-a-good-thing\" class=\"heading-anchor\" aria-label=\"Permalink for Discrimination can be a good thing\" tabindex=\"-1\"><\/a>Discrimination can be a good thing<\/h3>\n<p>Before you get your pitchforks out, I'm talking about technical discrimination.<\/p>\n<p>You have the option when using CloudFlare to only enable it on certain subdomains.\nAgain this is best explained by an example of how I have things configured, but your mileage may vary.\nWhat&#39;s important to note here is all of these services are running on my home server, that also has some inbuilt defences including <a href=\"https:\/\/www.crowdsec.net\/\">CrowdSec<\/a> which is a topic for another day.<\/p>\n<table>\n<thead>\n<tr>\n<th>Service<\/th>\n<th>CloudFlare connection method<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Authentik<\/td>\n<td>Direct TLS connection<\/td>\n<\/tr>\n<tr>\n<td>Home Assistant<\/td>\n<td>Direct TLS connection<\/td>\n<\/tr>\n<tr>\n<td>Grafana<\/td>\n<td>CloudFlare proxy<\/td>\n<\/tr>\n<tr>\n<td>Recipe book<\/td>\n<td>CloudFlare proxy<\/td>\n<\/tr>\n<tr>\n<td>Matrix<\/td>\n<td>CloudFlare tunnel (providing dynamic fail-over to GSM for status monitoring)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Hopefully this demonstration shows partially how I make a decision about what level of access CloudFlare have.\nAnything involving potentially sensitive content (such as passwords) in plain text always uses a direct TLS connection, services that just provide content are proxied for protection\/speed boosts, and in the case of Matrix, <code>cloudflared<\/code> tunnels are used to provide automatic fail-over to a mobile data connection as this is used for some alerts.\nI get to discriminate based on the context what is important to me.<\/p>\n<h2 id=\"im-usually-wrong-about-these-things-but-so-are-you\" class=\"heading\"><a href=\"#im-usually-wrong-about-these-things-but-so-are-you\" class=\"heading-anchor\" aria-label=\"Permalink for I&#39;m usually wrong about these things, but so are you\" tabindex=\"-1\"><\/a>I&#39;m usually wrong about these things, but so are you<\/h2>\n<p>Please don't take my word for anything I've written here, it is almost entirely opinion and what works for me, my setup, and my guiding values, is highly unlikely to work for you.\nI've been hosting things online for a decade now, the internet landscape has changed drastically, as has my approach to things.<\/p>\n<p>In short, in the capacity they have access to my data, I trust CloudFlare.\nWhile them centralising the internet is a bad thing, they have so far shown themselves to be responsible custodians of this power and have not abused it.\nHistorically they have had issues with anonymous access which would ordinarily be a red flag, but recent decisions to provide Tor hidden services and replacing ReCAPTCHA first with <a href=\"https:\/\/www.hcaptcha.com\/\">hCaptcha<\/a> then their own Turnstile service show a new commitment to protecting this.\nI&#39;m mindful of what plaintext access they have to data I host and the drawbacks that come from it.<\/p>\n<p>For now, they will continue to get my support, usage, and registrar business.\nThe only thing I can say for certain is I will continue to make things a vendor-agnostic as possible so should CloudFlare change, I can change as well.<\/p>","url":"https:\/\/itsg.host\/2023\/on-cloudflare-and-selfhosting","title":"On CloudFlare & Self Hosting","date_modified":"2023-09-13T00:00:00.000Z","tags":[]}]}