Hi all, I’m running a small website off of a raspberry pi in my house. I have opened ports 80 and 443 and connected my IP to a domain. I’m pretty confident in my security for my raspberry pi (no password ssh, fail2ban, nginx. Shoutout networkchuck.). However, I am wondering if by exposing my ports to the raspberry pi, I am also exposing those same ports to other devices in my home network, for example, my PC. I’m just a bit unsure if port forwarding to an internal IP would also expose other internal IP’s or if it only goes to the pi. If you are able to answer or have any other comments about my setup, I would appreciate your comment. Thanks!

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

    I have my services proxied through nginx and behind cloudflares free tier. That way I don’t have to worry about my IP getting exposed and opening myself up to DDOS/DOS attacks, which is a genuine threat if you do things that piss people off (I’m an admin on a popular minecraft server).

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

      I looked into nginx for minecraft, but minecraft doesn’t use http headers, so I’d have to open minecraft ports on the router. Would this alleviate that? What’s the difference between this setup and using something like a cloudflare tunnel? Obviously, there is still some reliance on Cloudflare.

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

      It’s 2023, the threat is there regardless if you piss anyone off. We’re all commodities that can/will be exploited for capitalistic gain.

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

    I would suggest signing up for a free Cloudflare account and setting up any DNS for your Pi through there, using the Cache feature.

    Once that is done, setup an automated script that will pull down Cloudflare IPs into a file (you can use a cronjob to run this daily):

    #!/bin/bash
    
    set -e
    
    cf_ips() {
      echo "# https://www.cloudflare.com/ips"
    
      for type in v4 v6; do
        echo "# IP$type"
        curl -sL "https://www.cloudflare.com/ips-$type/" | sed "s|^|allow |g" | sed "s|\$|;|g"
        echo
      done
    
      echo "# Generated at $(LC_ALL=C date)"
    }
    
    cf_ips > allow-cloudflare.conf
    (cf_ips && echo "deny all; # deny all remaining ips") > allow-cloudflare-only.conf
    

    Then in your web server config to only accept connections from Cloudflare IPs:

    server {
    	listen 80 default_server;
    	listen [::]:80 default_server;
    	server_name example.com;
            root /var/www/html;
    
    	include /etc/nginx/allow-cloudflare-only.conf;
    }
    

    I prefer this method over UFW/iptables block as it allows you to control the IP block per web config, so if needed, you can make exceptions by not adding the include /etc/nginx/allow-cloudflare-only.conf; into that specific site’s conf file.

  • 64bitUser@lemmy.world
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 year ago

    If you port forward to your Pi, only your Pi will be exposed. But, if your Pi gets pwned, it can in turn attack anything next to it. Safest is to isolate the Pi on it’s own subnet or a DMZ if your router has the functionality.

    Of note, many home ISPs block standard server ports like 80 and 443. You might need to use non standard ports like 8080 and 8443

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

    You could put the pi on its own subnet. That way if it’s hacked, the rest of the network is protected. Just make sure your router admin interface doesn’t answer on that subnet.

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

      You could put the pi on its own subnet.

      This option is sometimes referred to as a ‘DMZ’ and may be supported by the router. Also look for VLAN options.

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

        DMZ in essence means “forward ALL ports” to X. You should only DMZ a host that you know is very secure as its attack surface is significantly increased. If you need just one or two services open, best to not use DMZ

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

    You are probably going to be ok unless someone really wants to hack you. The LastPass hack that exposed passwords of millions of people started from an open port in the home network of one of their engineers.

    If you want to be somewhat safer, you could try something like the cloudflare tunnel thing to proxy your home network through their server.

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

      Honestly depends on what he’s hosting… Services like shodan are constantly scanning the web and are trying to see what is actually running in the machine.

      If he’s serving something that’s vulnerable and has rce it won’t take too long for him to get automatically pwned.

      We’ve seen this with the hafnium Echange vulnerability and all known vulnerable public facing web apps that used log4j.

      Regarding the LastPass breach, the second part of the breach was using a very outdated version of Plex. Chances are high that his home machine was already hacked by other malicious actors.

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

    I did this for some time. But now I don’t want any ports open at home.

    That’s why I have a rented VPS that runs Traefik (a reverse proxy). This VPS has a VPN connection to my home net and is behind Cloudflare DNS. This is how I can safely expose services (even in my home net) to the Internet without forwarding any ports.

    Of course those services need to have some kind of authentication.

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

        If this was “top security” I’d need to change jobs, haha! I just hope it doesn’t fall apart and nobody breaches it too easily.

        Currently there are probably a lot of attac vectors available, that I’m not even aware of. I just have to hope, that my stuff won’t become interesting for a bad actor.

        Nothing to see here, move along. I have a few locks, not worth it… :D

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

      If you’ve set up a VPN to your home net then why not run that VPN from the devices you use to access the reverse proxy? With wireguard at least this is quite easy.

      That way you don’t have to expose anything you just run a VPN with the reverse proxy in it.

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

        My setup is

        Internet <—> Reverse Proxy (on VPS) <—> OpenVPN Server (on VPS) <—> VPN Client (home router) <—> local stuff…

        I don’t understand what you mean? Generally I don’t like to require a VPN to access stuff. My use case is, when I’m away I’d like to be able to access things from e.g. a public device, a friends laptop, etc. That’s why I’m not using a VPN to access things.

        The VPN site-to-site connection is mainly responsible to make network shares available on my Nextcloud instance and provide access to other (local) services via the reverse proxy

        Currently I’m rethinking the VPN, but I don’t think I can ditch it in favor if e.g. Cloudflare Access tunnels (too unflexible, limited compatibility, or too much hassle to keep everything configured correctly).

        Also, I don’t use VPN to authorize requests. I use Authelia to authorize users with Free-IPA as directory in the backend.

        I know, this might be overkill for my “simple” use cases, but I like to play around with these kind of enterprise-adjacent solutions.