Hey all! For the longest time I’ve had a server that hosts some things (eg Syncthing), but is only available via SSH tunneling.

I’ve been thinking of self-hosting more things like Nextcloud and Vaultwarden. I can keep my SSH tunneling setup but it might make it difficult to do SSL.

How do you manage the security of having public-facing servers?

  • hib@lemmy.sdf.org
    link
    fedilink
    English
    arrow-up
    12
    ·
    edit-2
    1 year ago

    Here is my setup:

    Cloudflare fronts all of my webserver traffic, and I have firewall rules in Cloudflare.

    Then I have an OPNsense firewall that blocks a list of suspicious ips that updates automatically, and only allows port 80/443 connections from Cloudflare’s servers. The only other port I have open is for Wireguard to access all of my internal services. This does not go through Cloudflare obviously, and I use a different domain for my actual IP. I keep Vaultwarden internal for extra safety.

    Next I run every internet facing service in k3s in a separate namespace. This namespace has its own traefik reverse proxy separate from my internal services. This is what port 80/443 forwards to. The namespace has network policies that prevent any egress traffic to my local network. Every container in the WAN facing namespace runs as a user with no login permission to the host. I am also picky about what storage I mount in them.

    If you can get through that you deserve my data I think.

    • skywhale241
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year ago

      I need to learn more about cloudflare. Do you have the guide for this setup!

      • hib@lemmy.sdf.org
        link
        fedilink
        English
        arrow-up
        3
        ·
        1 year ago

        Unfortunately no guide, just things I’ve pieced together myself over the years.

        Cloudflare is probably the easiest and most intuitive part of the setup though, you can setup dns/proxy/firewall rules very intuitively, and I’m sure there are plenty of guides out there.

        • kylian0087@lemmy.world
          link
          fedilink
          English
          arrow-up
          3
          ·
          1 year ago

          Becarefull not everything is allowed true clousflare. I believe officialy only web content is. So having nextcloud behind it for example to upload and download files. Is as far as i am aware against the TOS.

            • donnnnnb@lemm.ee
              link
              fedilink
              arrow-up
              1
              ·
              1 year ago

              I was looking into this for Plex the other day. There’s some conflicting information on the internet right now. From what I can tell, large non-HTML content still seems to be against their ToS, unless you’re an Enterprise customer or serving the files/media with CloudFlare’s R2 or Stream services. I hope I’m wrong though, if someone can confirm.

              This post from CloudFlare explains the recent changes to their ToS, and the CDN ToS appears to disallow media or large file content.

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

            To clarify, that is only the Cloudflare Tunnel service that has the “only do web traffic” ToS rule. Tunnel is their service that eliminates the need for port forwarding from your home network.

            My understanding is that cloudflare DNS can also be a reverse proxy for you and still provide some benefit your security (though, unlike the tunnel service, you do need to expose ports from your home network to the internet).

  • Faceman🇦🇺@discuss.tchncs.de
    link
    fedilink
    English
    arrow-up
    10
    ·
    1 year ago

    It’s always a risk, but it comes down to trusting that the services you host are secure enough, and that your skill in making them public keeps them safe.

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

      Mostly a convenience thing, since I only need it on-demand and I usually use SSH for things anyway. As this post suggests I’m obviously rethinking that now :)

      • njinx@lemmy.world
        link
        fedilink
        English
        arrow-up
        4
        ·
        edit-2
        1 year ago

        A VPN you could use on your phone, computer, laptop, tablet, TV, Samsung SmartFridge, etc. I’ll admit it’s a bit more involved than ssh -L ... but it’s well worth it. Especially if you’re the only one using it. After setting up Wireguard I’ve elimated all my router port forwards except SSH and WG

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

    Look into tailscale it was really easy to setup for a VPN. You can expose web services with cloudflare and a domain name.

    • Strange_Meadowlark@lemmy.world
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year ago

      Yup, I’m also using Cloudflare tunnels with a private domain. The docs saying what to do on Cloudflare’s side weren’t that easy to find though. It’s too easy to accidentally fall into their docs on Argo Tunnels or the “zero-trust” thing.

      Once it’s set up though, it’s really awesome

  • albsen@lemmy.world
    link
    fedilink
    English
    arrow-up
    6
    ·
    1 year ago

    Yes you should be worried. Dont expose services you’re not able to keep up to date and know how to manage and secure. Using tailscale is a great alternative as it allows you to have access without exposing anything to the internet, I’d prefer that. For everything else, subscribe to a CVE service for those (I use nextcloud and matrix and follow all security findings) and be ready to take them offline as soon as a critical exploit appears. Dont expose your passwords directly to the internet - ever; no matter if anyone else tells you its OK.

  • #!/usr/bin/woof@lemmy.sdf.org
    link
    fedilink
    English
    arrow-up
    5
    ·
    1 year ago

    Yes. I used to do that when I had no other option. In my early days I managed to get a worm spread by a susceptible sshd in… red hat 5ish… don’t remember exactly. But the point being: keeping things secure is hard work. And even then it might not be possible.

    These days I use tailscale and essentially never leave my internal network regardless of being directly connected to it or not.

    Set it up with your own DNS server and tailscale’s ability to forward specific domains to your DNS server and it all just works.

  • cichy1173@szmer.info
    link
    fedilink
    English
    arrow-up
    4
    ·
    edit-2
    1 year ago

    You should be concerned, because there is always a risk, but there is also a risk when you are just using internet even without selfhosting. It is good to remember some rules:

    1. Keep apps up to date
    2. Open only that ports, that you need (80, 443, maybe 22 for ssh)
    3. If you open ssh port, use keys authentication and cut possibility logging with password
    4. Do not expose apps, that you are not need in this form, for example Yunohost allows to hide apps behind Yunohost SSO logging page
    5. Using cloudflare or/and Fail2Ban is cool
    6. Maybe I am a little bit paranoic, but I do not expose apps, that can be used anonymously by everyone, for example link shorters or pastebin alternatives.

    It is not all of course.

    • Longpork_afficianado@lemmy.nz
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year ago

      I would add to this, disable icmp response on any internet facing server that does not aboluetly require it, it make it whitelisted to your know IPs when it is. If your server does not appear online then you will only really be vulernable to targeted attacks where your ip is already known.

  • returnofblank@lemmy.world
    link
    fedilink
    English
    arrow-up
    3
    ·
    1 year ago

    Password protect your services, set up your web server correctly, use cloudflare for some extra security against stuff like DDoS/DoS attacks. Also less is more, do not expose what you don’t need to expose.

    There is always inherent risk with opening up your stuff to the world wide web.

    Some stuff you can’t even secure yourself; some services just have bad security practices. The only way to fix them would be to wait for an update or submit a pull request.

  • Invelyzi@kbin.social
    link
    fedilink
    arrow-up
    2
    ·
    1 year ago

    Either tailscale the network and not worry about it being “public facing” or if it must be somewhere in the denizens then an outbound only connection between a secure remote server and my server.

  • Shortcake@kbin.social
    link
    fedilink
    arrow-up
    2
    ·
    1 year ago

    i use strong passwords and cloudflare tunnels with zero trust. if a site has an option to run without needing https, i use wireguard or tailscale

  • Midou@kbin.projectsegfau.lt
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    Isolate your programs, keep the critical stuff away from the public using tailscale or a VPN, hell, even an SSH tunnel could work in your case, make sure to keep different password for each software for your database. If possible virtualize each software to keep them from communicating to other softwares. This is how i manage my infrastructure (or should be, i haven’t gotten yet to use tailscale for admin only websites).

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

    thank you so much for all the suggestions!

    My biggest takeaway from all this is managed VPN solutions like Tailscale are cheap ($0), easy to set up, and lets me not expose ports to the outside world.