Hi, I know this topic has been talked about 70 thousand times but I’m still not sure.

I have home server on an intel NUC behind the ISP router. On it I have the standard arr apps, jellyfin, pi-hole etc etc. I would like to access them through a domain rather than an IP. So I set them up in docker, behind traefik, behind authelia and behind cloudflare. I am the only one that uses it.

Now, I’m worried about the security of it all. I’ve been searching here and there and I’ve read about cf tunnels, wireguard server, vps, vlan, OPNsense etc etc. I still don’t know what would be the most secure. Should I just stay with what I have?

EDIT: I’m not behind CGNAT

  • Nyfure
    link
    fedilink
    32 years ago

    If its only you and you want best security, setup a VPN system. (Tailscale, Netbird, or others are quite easy)
    If someone else should also, and you dont want everyone to have to use a VPN, then you can expose some services directly. Of course behind CGNat you need some third-party system to allow this (e.g. cloudflare or a rented server).

    I am not a big fan of cloudflare, they are a huge centralized company, easily allowing tracking across websites with clear-text access and kinda discouraging learning how to secure things yourself (which you have to do anyways, because you are a service provider and only cloudflare is not enough if its still publicly accessible though them)
    But in the end its your choice. They easily allow you as service provider to protect yourself from DDoS attacks or allowing IPv4 access when you are behind CGNat, things you just cannot easily do yourself, certainly not without costs.

  • @[email protected]
    link
    fedilink
    English
    62 years ago

    Why so complicated? Why not just SSH? Put it on some random port, make it public key login only, and you’re done.

    • ExploratrixLunae
      link
      fedilink
      12 years ago

      I’ve beeb looking into a similar setup and I didn’t know SSH could do this kind of tunneling. Thanks for the tip! I’m going to consider using it.

      • @[email protected]
        link
        fedilink
        English
        12 years ago

        I’m not sure what you mean by tunnel, but SSH allows a “secure shell” aka an encrypted connection to a shell on a device. Tailscale, Headscale, and others are VPNs, which means they allow making it seem as if your computer is in the same (private) network as that of the server - but in order to have a shell on the server, you’ll still need SSH.

        To my knowledge, adding a VPN to open a secure shell on the server is unnecessary and has no security benefits.

    • Eris
      link
      fedilink
      English
      12 years ago

      This is what I do and I’ve wondered why people always shill for tailscale or cloud flare tunneling, seems like way too much extra bs for the same thing

  • @[email protected]
    link
    fedilink
    English
    62 years ago

    It largely depends on what you mean by ‘anywhere’, in particular if you only want to access it from your own devices or also other people’s you can only access for a minute or two and where you can’t install anything.

    Of course there is also the question which services you want to access, e.g. just Websites and -Applications over HTTPS or do you also want e.g. the pi-hole’s DNS service to be available.

    • Footnote2669OP
      link
      fedilink
      English
      12 years ago

      My own devices. Mostly over https. Pi-hole would be nice, but not necessary.

    • Footnote2669OP
      link
      fedilink
      English
      42 years ago

      I might, but I’m gonna explore the open source solutions first :)

      • Nis
        link
        fedilink
        English
        102 years ago

        I’ve been using Tailscale, it’s lovely. But I didn’t like that I had to use Google/Apple/Github to log in.

        Last night I set up a Headscale server which works with the tailscale client. It’s lovely as well.

  • @[email protected]
    link
    fedilink
    English
    452 years ago

    I would go with wireguard VPN or something like cloudflare tunnels or tailscale. With wireguard you’ll need to open up an external port and forward to your VPN host, but wireguard uses UDP so no one can probe it for responses. CF tunnels and tailscale you don’t have to open up holes in your firewall which is nice.

    You also have the option of using a proxy and opening up 443 publicly on your firewall, but unless you know what you’re doing I’d leave that closed until you learn more.

  • @[email protected]
    link
    fedilink
    English
    22 years ago

    My router supported OpenVPN out of the box so I just use that and have remote connections disabled in all of my software

    I’m curious what the other, more advanced users here have to tell me about it because I’m still new to the self hosted stuff and that was the first thing I thought of to do

    • @[email protected]
      link
      fedilink
      English
      2
      edit-2
      2 years ago

      This is what I use too. Also using the provided dynamic dns server just makes this dead simple and has been working for years. Is there a good reason to switch?

    • @[email protected]
      link
      fedilink
      English
      2
      edit-2
      2 years ago

      Wireguard is just much faster connection-wise. Built into the kernel too. Since it came out I haven’t gone back to openvpn.

      Nothing wrong with openvpn otherwise. More config options.

      Something like Tailscale makes wireguard setup dead easy.

  • @[email protected]
    link
    fedilink
    English
    41
    edit-2
    2 years ago

    Yes, you can use a Cloudflare tunnel but why? Since you’re into self-hosting why should you depend on some random company to tunnel your traffic when you most likely don’t need it? You also have all the potential tracking, spyware, risks and “being hostage” scenarios that may come with that choice.

    The following assumes your use case is a simple home server for “standard arr apps, jellyfin, pi-hole” for personal usage that sits inside your network and your objetive is to be able to access those services. If you’re instead trying to host a game server / few services for friends (that doesn’t really need to be “inside” your home network) there’s a more complete comment with other security considerations and recommendations here.

    Your basic requirements are:

    • Some kind of domain / subdomain payed or free;
    • Preferably Home ISP that has provides public IP addresses - no CGNAT BS;
    • Ideally a static IP at home, but you can do just fine with a dynamic DNS service such as https://freedns.afraid.org/.

    Quick setup guide and checklist:

    1. Create your subdomain for the dynamic DNS service https://freedns.afraid.org/ and install the daemon on the server - will update your domain with your dynamic IP when it changes;
    2. List what ports you need to access remote;
    3. Setup Wireguard VPN on the server. There’s also this nice UI that can be used to do most of the setup and create client config files;
    4. For the VPN use custom ports with 5 digits - something like 23901 (up to 65535) to make your service harder to find;
    5. Configure your ISP router to assign a static local IP to the server and port forward the VPN port to the server IP;
    6. Only expose absolutely required services (the VPN port in this case) to the Internet. Any service the server provides, SSH, configuration interfaces and whatnot can accessed through the WireGuard VPN;
    7. In the server consider setting up nftables / iptables / another firewall 10 minute guide;
    8. Configure nftables to only allow traffic coming from public IP addresses (IPs outside your home network IP / VPN range) to the Wireguard port - this will protect your server if by some mistake the router starts forwarding more traffic from the internet to the server than it should;
    9. Configure nftables to restrict what countries are allowed to access your server. Most likely you only need to allow incoming connection from your country (https://wiki.nftables.org/wiki-nftables/index.php/GeoIP_matching).

    Since you’re only allowing access to your services through the VPN and you’ve heavily restricted access to the VPN port you’ll be safe. Just a side note, don’t be afraid to expose the Wireguard port because if someone tried to connect and they don’t authenticate with the right key the server will silently drop the packets.

    Now if your ISP doesn’t provide you with a public IP / port forwarding abilities you may want to read this in order to find why you should avoid Cloudflare and how to setup and alternative / more private solution.

    • Footnote2669OP
      link
      fedilink
      English
      32 years ago

      Thanks for this awesome write-up.

      Yeah, that’s what I’m kind of thinking about Cloudflare, so I’m trying to set up WireGuard right now. I don’t know if I’m shooting myself in the foot by trying to do in docker for now or not, but I’d rather do that before I do it on bare metal. It seems to work already, as I can see that my IP changes on my phone when I access it. Hell, I can even access my routers’ dashboard. However, I still can’t access the services on the server (by IP, like 192.x.x.x:8989), so I’m trying to figure that out.

      May I ask, why do I need a domain if I’m going through WireGuard, which goes through the IP and port, anyway?

      • @[email protected]
        link
        fedilink
        English
        32 years ago

        If your home ip changes a lot a dynamic dns provider will keep up with it so you don’t constantly have to change your phone’s wireguard configuration

        • Footnote2669OP
          link
          fedilink
          English
          12 years ago

          Ohhhhh, that makes sense. I might consider it in the future. I don’t think it changed once so far. If it does, I’ll come back to that, thanks :)

      • lemmyvore
        link
        fedilink
        English
        1
        edit-2
        2 years ago

        Before you invest a lot of time into this just wanted to say that it’s a 2m job with Tailscale. You install it on the server and on your phone (or laptop whatever), you start it, and you can access anything on the server at a short name you can customize fully, or at a long name you can pick from randomly generated choices generated by Tailscale. (The long name is usually only relevant if you’re going to expose your server to the internet or in unusual DNS setups, if you just want to access the server from your phone the short name will do.)

        OP’s list is great for learning and for full control but if you just want to solve your problem fast, you can.

        • Footnote2669OP
          link
          fedilink
          English
          32 years ago

          I’m either lucky or it’s stupid easy to install wireguard. I put basic config in docker compose, downloaded the app, port forwarded and I’m good. Even pihole works. It’d haven taken me 5 mins if it wasn’t for the firewall

          • @[email protected]
            link
            fedilink
            English
            12 years ago

            Dont listen to people about tailscale. This is self hosting! Do it yourself it’s part of the fun. I don’t know why people are shilling corporate entities so hard here.

          • Yas
            link
            fedilink
            English
            32 years ago

            One of the other benefits of Tailscale is device management. Wireguard is an awesome tool (Tailscale uses it under the hood), but adding new devices is more work with Wireguard, as you have to generate keys and share the public keys (and do some IP management). With Tailscale it’s pretty much install the app and allow the device with a click.

    • Footnote2669OP
      link
      fedilink
      English
      22 years ago

      I have an Intel NUC with i3-4010U, 8GB of RAM and 250GB of storage. Got it for 50GBP off of eBay. Unfortunately, I have to delete shows/movies to watch another, as there isn’t much space, but it manages :)

      (I should be paid for how many times I have mentioned this lmao) I used this smarthomebeginner.com. If you follow this guide, you should be good to go :)

  • Encrypt-Keeper
    link
    fedilink
    English
    10
    edit-2
    2 years ago

    I use Tailscale with their DDNS feature that generates you a domain that resolves each of your Tailnet devices when connected. You can even run a command that generates an SSL cert for your given node and you can use that to further secure it with TLS in case you don’t want to deal with untrusted cert warnings.

    This is especially useful for iPhones because they won’t keep your Tailscale VPN always on, but you can configure it so that requests to specific domains will activate and use your Tailscale VPN, which you just set to that generated one.

    • @[email protected]
      link
      fedilink
      English
      12 years ago

      I was about to ask why you’d need DDNS for Tailscale, had no idea about iOS issues. Thanks!

      • Encrypt-Keeper
        link
        fedilink
        English
        32 years ago

        Because even when you have static IPs it’s still nice to just use a host name, and to properly secure things with a certificate. It’s not really DDNS as much as it is plain old DNS, but it works without configuration on your part. Once you enable it, whatever the tailnet name of your device is, becomes ‘device name.yourdomain.ts.net’.

  • @[email protected]B
    link
    fedilink
    English
    8
    edit-2
    2 years ago

    Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I’ve seen in this thread:

    Fewer Letters More Letters
    CF CloudFlare
    CGNAT Carrier-Grade NAT
    DNS Domain Name Service/System
    HTTP Hypertext Transfer Protocol, the Web
    HTTPS HTTP over SSL
    IP Internet Protocol
    NAS Network-Attached Storage
    NAT Network Address Translation
    NUC Next Unit of Computing brand of Intel small computers
    SSH Secure Shell for remote terminal access
    SSL Secure Sockets Layer, for transparent encryption
    TLS Transport Layer Security, supersedes SSL
    UDP User Datagram Protocol, for real-time communications
    VPN Virtual Private Network
    VPS Virtual Private Server (opposed to shared hosting)

    [Thread #319 for this sub, first seen 1st Dec 2023, 09:55] [FAQ] [Full list] [Contact] [Source code]

  • Sparking
    link
    fedilink
    English
    12 years ago

    My advice: only forward ports 8080 and 443, then make sure that you have fail2ban or crossed properly set up on your reverse proxy. After that, you are pretty much fine as long as you keep on top of updating your containers.

    I would be careful about which apps you proxy. Idk why you need to access the admin portal for pi hole worldwide. If you really want to do that, you should set up a vpn.

  • Possibly linux
    link
    fedilink
    English
    22 years ago

    First off, don’t expose anything that doesn’t need exposed. If your the only one using it you could use a VPN or ssh.

    Second off, make sure you isolate everything with firewalls. Your reverse proxy should only have access to each service and each service should only have access to the reverse proxy. You should also block non essential ports.

    For the services themselves, make sure you use strong passwords and keep them updated. For docker you can use watchtower to automatically pull and deploy software.

  • @[email protected]
    link
    fedilink
    English
    22 years ago

    I’d say to start with CF tunnels unless you need non-web based applications. Cloudflare tunnels require you to have a domain, though.

    It has the added benefit that you have network monitoring, logging and some filtering for security that they do on top and you get to manage everything from their web interface.

    be warned that the first time can be a bit confusing, but since it’s done using their web interface it’s easier than if you have a problem making wireguard work.

    1. Create a tunnel with a public hostname that will be the url to access that service. During the creation of the hostname specify you want it protected by L7 application firewall.
    2. Create a new self-hosted application in cloudflare application section and for starters use the default login email and in rules specify the list of emails that are allowed to login

    you should now be able to access your application from anywhere.

    Alternatively, if you have a DNS server in your home network you can add a private IP range to your tunnel. Let’s say 192.168.0.0/24. Then when you connect with their pseudo-VPN (cloudflare warp or cloudflare ONE) you can directly use your home network’s ip address from that device. If you tell your device to use a local DNS server that resolves your internal services, you’ll be able to connect to them that way.

  • @[email protected]
    link
    fedilink
    English
    82 years ago

    Make your services password protected and have some software like fail2ban that blocks people from brute-forcing passwords.

    Keep your software up to date.

    • Footnote2669OP
      link
      fedilink
      English
      12 years ago

      They are password protected. Plus, behind 2FA authelia. Plus Crowdsec (which originally made me make this post, cos I can see http probing etc on it)

      • @[email protected]
        link
        fedilink
        English
        2
        edit-2
        2 years ago

        Alright. I wouldn’t worry too much, then. If you set it up correctly and you keep it up to date so there aren’t any security vulnerabilities, you should be okay.

        Of course there are arbitrary, more strict approaches. You could do monitoring. Or restrict the IP addresses the server answers to. Or put everything behind a VPN and not have it exposed in the first place. But I also have my NAS and a few internet services like Nextcloud and it’s been fine, similar to this, for years.

        • @[email protected]
          link
          fedilink
          English
          22 years ago

          Same, have had a few select services exposed to the internet, behind very, very complex passwords or keys, with fail2ban etc. never had an incidence.