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!

  • themoonisacheese@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    5
    arrow-down
    1
    ·
    1 year ago

    Quick question: why? Why not choose to host a server in the US, near it’s “costumer base”?

    If you’re doing it for the exercise, fine (though I think you’ll find that cloud flare is pretty hands-off and you basically just click a few buttons).

    If you’re genuinely looking to improve cross-planet load times, I regret to inform you that a personal Lemmy instance is very much not a good target for this. A CDN works by hosting whatever parts of your site you can nearer to the people who will request them. For a huge company like discord, this means that when you upload an image to a server, they will sum up all users likely to load that image soon, find where they are and send a copy of that image nearby, saving on intercontinental traffic. They get to do this because they have many users, and they control the CDN (because they built it).

    You on the other hand, are going to ask cloud flare nicely to do all of this for you. Since you aren’t paying, cloud flare is going to try to do this automatically and without cooperation from your software. This means that cloud flare will basically only try to cache parts of Lemmy that are static, so really only the page layout and that’s about it. Ultimately, the Lemmy website for your instance might load a little bit faster, but posts can’t be predicted and so those will have to go cross-continental on a cache miss.

    The other advantage this affords is that anyone interested in taking down your instance will have to take it up with cloud flare. If the way they’re trying is brute force, they will fail where they would have succeeded against just your server. If their way of doing it is through legal threats, they might have better luck (though cloud flare tries to remove itself from a position where they have to police what their service can be used for, my opinion is that it is a matter of time before they are forced to).

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

      Thank you for the wonderful comment!

      The only reason I’m looking to host in Europe is because of the prices: this server will not allow for sign-ups (i.e. it will only be for me). I will likely only need 1GB of RAM and very little CPU power to get this to work. The prices in Europe for low-cost VPSes are better than in the US. I don’t actually care about which country/continent I’m hosting it in, this decision was purely financial.

      I have a question: I believe I can set Lemmy to auto-sync content from communities I’m interested in (I can set the frequency for the auto-sync) - would it be possible for Cloudflare to cache the content if it is already in the database of my Lemmy instance? I know that CDNs can only really cache static content but I do not know enough about CDNs/Cloud Networking in general to be able to figure out just what it would be able to cache.

      Thank you, yes I had the protections offered by Cloudflare in mind when I asked this question. I do not plan to do anything illegal so I hope I’ll be fine.

      Could you also tell me why Cloudflare asks me to change the authoritative nameservers on my registrar’s page to their nameservers? I think my networking is getting a bit rusty, I really can’t figure it out.

      One more thing; is there a difference in configuring a Cloudflare CDN vs a Cloudflare reverse-proxy for a VPS instance? I see people in c/homelab talk about this but I never really delved into it, but if I could access my network remotely using this it would a great bonus.

      Thanks!

      • themoonisacheese@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        4
        ·
        1 year ago

        Adding to the hetzner comment: I think AWS has free very crappy servers. If you’re a student, the Github Student Pack has free digitalocen credits.

        In theory, cloud flare could pre-cache content before you request it. Unfortunately, that would require significant effort from Lemmy to let cloud flare know that there is new content, and then it would be up to cloud flare to decide to cache it for 1 client. Both these things aren’t happening.

        CF needs to dynamically control where requests for your server end up, and for that they need to be the authoritative DNS for it.

        Cloud flare indeed acts as a reverse proxy (because that’s how CDNs work), but unlike a self-hosted reverse proxy, theirs will be on their servers, so will not have much more more access to your network than yourself outside of it. I think they have some sort of offering to actually give your more access, but A) idk if that’s free and B) that requires an always-on computer in your local network, at which point why not just host your Lemmy instance on it?