Hi, I wanted to host a personal Lemmy instance online (for just myself, I don’t think I can take the upkeep for other users - please let me know if this is not possible) and wanted to understand how to “attach” a CDN service to it.

The idea behind doing this is that I’m in the US but I’m looking to host a server in Europe. I am looking into Cloudflare’s free CDN service, but it would be great if someone could point me towards how I can configure this setup to speed up the loading time for my Lemmy instance (which is going to be far away from me, geographically).

I would also like to know about your setups and how you have hosted Lemmy.

Thanks!

  • MigratingtoLemmy@lemmy.worldOP
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    Ah, perfect. My hypothesis was correct!

    Haha, I’m aware I’m probably trying to delve deeper than most users, but I really want to understand the technology I plan to use. I am also very interested in Networking and such concepts intrigue me!

    Could you tell me how proxying traffic would work if they just asked the user to create a CNAME rather than using their nameservers? I still can’t figure this part out.

    My apologies for asking so many questions, but I just can’t seem to rest till I wrap my head around this :)

    • oranki@sopuli.xyz
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year ago

      No need to apologize.

      You’d create a CNAME for myservice.mydomain.com, that points to proxynearorigin.cloudflare.com.

      proxynearorigin.cloudflare.com contains the A and AAAA records for the reverse proxy servers. When you do a DNS query for myservice.mydomain.com, it will (eventually) resolve to the CF proxy IPs.

      The CF proxies see from the traffic that you originally requested myservice.mydomain.com and serve your content based on that. This still requires you to tell Cloudflare where the origin server is so the reverse proxies can connect to it.

      On the free service instead of the CNAME you set the origin server’s IP as the A and/or AAAA record. Enabling the proxy service actually changes this so that when someone makes a DNS query to myservice.mydomain.com they get the proxy addresses straight as A and AAAA records, leaving the IP you originally configured known only to Cloudflare internally.

      It’s hard to explain this, and since I don’t work at Cloudflare the details may be off too. The best way to get an idea is play around with something like NGINX and run a local DNS server (Bind, Unbound, dnsmasq, PiHole…) and see for yourself how the DNS system works.

      CDN isn’t really related to DNS at all. In the case of the CF free tier, it’s actually more like caching static content, which is technically a bit different. A CDN is a service that replicates said static content to multiple locations on high-performant servers, allowing the content to always be served from close to to the client. Where DNS comes in is that Anycast is probably used, and cdn.cloudflare.com actually resolves to different IPs depending on where the DNS query is made from.

      There’s also the chance that I don’t actually know what I’m talking about, but luckily someone will most likely correct me if that’s the case. :)