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
    5
    ·
    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
      1
      ·
      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
      1
      ·
      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.

  • surewhynotlem@lemmy.world
    link
    fedilink
    English
    arrow-up
    1
    ·
    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.

  • 64bitUser@lemmy.world
    link
    fedilink
    English
    arrow-up
    1
    ·
    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

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

    The port forward only forwards to a single device so you aren’t exposing your PC (directly anyway). Sounds like you have the pi good and secured but if you wanted to add another layer you could segment it out into a DMZ or its own VLAN. That way if something did happen with it an attacker couldn’t move laterally inside your network.

    Realistically though you’re in good shape.

  • entropicshart@lemmy.world
    link
    fedilink
    English
    arrow-up
    1
    ·
    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.