I’m pretty new to selfhosting and homelabs, and I would appreciate a simple-worded explanation here. Details are always welcome!

So, I have a home network with a dynamic external IP address. I already have my Synology NAS exposed to the Internet with DDNS - this was done using the interface, so didn’t require much technical knowledge.

Now, I would like to add another server (currently testing with Raspberry Pi) in the same LAN that would also be externally reachable, either through a subdomain (preferable), or through specific ports. How do I go about it?

P.S. Apparently, what I’ve tried on the router does work, it’s just that my NAS was sitting in the DMZ. Now it works!

  • tofu@lemmy.nocturnal.garden
    link
    fedilink
    English
    arrow-up
    63
    ·
    1 day ago

    You need a reserve proxy. That’s a piece of software that takes the requests and puts them toward the correct endpoint.

    You need to create port forwards in the router and direct 80 and 443 (or whatever you’re using) toward the host of the reverse proxy and that is listening to on those ports. If it recognized the requests are for nas.your.domain, it will forward the requests to the NAS.

    Common reverse proxies are nginx or caddy. You can install it on your raspberry, it doesn’t need it’s own device.

    If you don’t want that, you can create different port forwards on your router (e.g. 8080 and 8443 to the Raspi) and configure your service on the Raspi corresponding. But it doesn’t scale well and you’d need to call everything with the port and the reverse proxy is the usual solution.

    • Allero@lemmy.todayOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      1 day ago

      There’s an issue with that first part. Do I configure it right? Should <domain>:8100 be redirected to 192.168.0.113:81 in this case?

      • infeeeee@lemmy.zip
        link
        fedilink
        English
        arrow-up
        10
        ·
        24 hours ago

        External 80 to internal 80 and external 443 to internal 443

        With this config you don’t have to deal with ports later, as http is 80, https is 443 by default.

        If you run some container on port 81, you have to deal with that in the reverse proxy, not in the router. E.g. redirect something.domian.tld to 192.168.0.103:81

        If you use docker check out nginxproxymanager, it has a very beginner friendly admin webui. You shouldn’t forward the admin ui’s port, you need to access it only from your lan.

        • Allero@lemmy.todayOP
          link
          fedilink
          English
          arrow-up
          2
          ·
          edit-2
          24 hours ago

          Actually, I do - 81 is exactly the default port for nginx proxy manager. I just tried to expose it as a testing example, and already closed it back after a success (apparently port forwarding worked just fine, it’s just that DMZ messed with it)

          And since we’re talking about this, what do I do with it next? I have it on my Pi, how do I ensure traffic is distributed through it as a reverse proxy? Do I need to expose ports 80 and 443 and then it would work automagically all by itself?

          • infeeeee@lemmy.zip
            link
            fedilink
            English
            arrow-up
            2
            ·
            22 hours ago

            You type the ip of the rpi on the router, so from an external call the router will forward it to the rpi. Or I don’t know what is your question.

            Things may seem automagical in the networking scene, but you can config anything the way you want. Even in nginxproxymanager you can edit the underlying actual nginx configs with their full power. The automagic is just the default setting.

            • Allero@lemmy.todayOP
              link
              fedilink
              English
              arrow-up
              1
              ·
              15 hours ago

              Where do I type rpi’s IP, just in port forwarding? Or somewhere else?

              I want for Nginx proxy, controlled through the Manager, to direct traffic to different physical servers based on subdomain.

              I put in nas.my.domain and I get my Synology on its DSM port. I put in pi.my.domain and I get a service on my Pi.

              • infeeeee@lemmy.zip
                link
                fedilink
                English
                arrow-up
                0
                ·
                10 hours ago

                It seems you are missing some very basic knowledge, if you have questions like this. Watch/read some tutorials to get the basics, than ask specific questions.

                This guy does the same thing as you: https://www.youtube.com/watch?v=yLduQiQXorc

                This was like the 3rd result for searching for nginxproxymanager on yt.

                • Allero@lemmy.todayOP
                  link
                  fedilink
                  English
                  arrow-up
                  1
                  ·
                  edit-2
                  9 hours ago

                  Guess I am going ahead of myself, yes, which gets even more complicated by having another server (Synology NAS) already installed and messing with networking a little, as internal settings appear to expect the NAS to be the only exposed thing on the network.

                  Thanks for the link! I’ve seen that thumbnail, but most guides are solely focused on actually installing Nginx Proxy Manager, which is the easy part, and skip the rest, so I glanced that one over.

                  P.S. Looks like I did everything right, I just need to sort my SSL stuff to work properly.

      • osaerisxero@kbin.melroy.org
        link
        fedilink
        arrow-up
        2
        ·
        24 hours ago

        This only guarantees your WANip:8100 will map to 192.168.0.113:81, and doesn’t address whether or not dns resolution is correct. I would also be weary of using port numbers on wikipedia’s known ports list, as some ISPs will filter those upstream. The last thing is that your router may not want to hairpin that traffic, so if you’re not coming in from the outside it might not be a valid test.

        • Allero@lemmy.todayOP
          link
          fedilink
          English
          arrow-up
          3
          ·
          23 hours ago

          Thanks for the pieces of advice! Yes, I tried to connect from external (mobile) network as well.