I created a short tutorial on using sub domains to access services hosted within my home network, thought I would share it here in case anyone finds it useful

This is the first time I’ve made a technical tutorial so apologise if there are mistakes/its confusing, feedback will be appreciated

    • Estebiu@lemmy.dbzer0.com
      link
      fedilink
      English
      arrow-up
      4
      ·
      14 days ago

      It works well, but if you want to do ‘custom stuff’ (like hosting a matrix instance) you’ll be out of luck

  • frongt@lemmy.zip
    link
    fedilink
    English
    arrow-up
    21
    arrow-down
    5
    ·
    16 days ago

    I am once again recommending that you not expose any services to the internet except a VPN

    • VeganCheesecake@lemmy.blahaj.zone
      link
      fedilink
      English
      arrow-up
      9
      ·
      16 days ago

      Good as a general recommendation.

      I also feel like the risk levels are very different. If it’s something that performs a function but doesn’t save/serve any custom data (e.g. bentopdf), that’s a lot easier to decide to do than something complicate like Jellyfin.

      I do have public addresses for Matrix, overleaf, AppFlowy, immich because they would be much less useful otherwise. Haven’t had any problems yet, but wouldn’t necessarily recommend it to others.

      I’d never host any stuff with “Linux ISOs” on a public adress, that seems like it’d be looking for trouble.

      • LordKitsuna@lemmy.world
        link
        fedilink
        English
        arrow-up
        4
        ·
        edit-2
        16 days ago

        I mean it WOULD work you would just need a von on every device you wanted to use.

        The REAL answer is never host them DIRECTLY, always use a reverse proxy like nginx. Many projects (i believe jellyfin is one of them) explicitly recommend this for better security. Which it looks like you did so congrats

        For extra bonus points you can setup nginx to run as a non privileged user and use iptables to forward the lower ports (80/443). A pain but closes out a large chunk of nginx as a risk.

          • LordKitsuna@lemmy.world
            link
            fedilink
            English
            arrow-up
            1
            ·
            15 days ago

            Eh, i just use pubkey only Auth config (so password entirely disabled as an option) and put ssh on a non standard port to reduce script kid noise. (and no 2222 is not non-standard it may as well be the default)

            Fail2ban triggers false too often for my taste in a high traffic environment.

    • Aneb@lemmy.world
      link
      fedilink
      English
      arrow-up
      2
      ·
      15 days ago

      Yeah it was honestly changing the router settings that was the hardest part for me, exposing port 22 and 80. Caddy was really easy to use

  • LievitoPadre@feddit.it
    link
    fedilink
    English
    arrow-up
    7
    ·
    15 days ago

    I did similar with caddy. I own a domain and my server runs pihole and it is configured as DNS server. So what I did was setup caddy to create local subdomains that are only reachable through my network. For example: subdomain.mydomain.com , that works only from home. It works with ssl as well

  • Mike Wooskey@lemmy.thewooskeys.com
    link
    fedilink
    English
    arrow-up
    0
    ·
    16 days ago

    Not positive, but I think you left in a reference to real info (twilightparadox.com) instead of “example-fying” it (mydomain.com), in the paragraph just before section 4:

    For example say I have home-assistant running on a Pi with the local address 192.168.0.11, I could create a subdomain named ha that has the value mysub.twilightparadox.com then create the following nginx config

    server{
    	listen 80;
    	server_name ha.mydomain.com;
    	resolver 192.168.0.1;
    	location / {
    		proxy_pass http://192.168.0.11/;
    	}
    }
    

    When nginx sees a request for ha.mydomain.com it passes it to the address 192.168.0.11 port 80.

  • BonkTheAnnoyed@lemmy.blahaj.zone
    link
    fedilink
    English
    arrow-up
    0
    ·
    edit-2
    16 days ago

    Very cool, great work!

    Worth noting about this approach is that the global list of subdomains is publicly searchable. So, you’ll see vulnerability and AI scans on those endpoints.

    If that’s a concern for you, using path-based routing (e.g. Apache VirtualHost) allows you to use difficult to guess paths to your cloud.

    • wildbus8979@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      0
      ·
      16 days ago

      Worth noting about this approach is that the global list of subdomains is publicly searchable.

      Can you expand on this? What is it that you call the “global list of subdomains”?

        • wildbus8979@sh.itjust.works
          link
          fedilink
          English
          arrow-up
          4
          ·
          16 days ago

          It’d be better and more accurate say the list of certificates then.

          Sub domains aren’t public unless your DNS server has XFER on.

        • wildbus8979@sh.itjust.works
          link
          fedilink
          English
          arrow-up
          2
          ·
          edit-2
          16 days ago

          Except it isn’t. Saying it is trivial is just gross generalization. It’s trivial to configure bind to have internal zones that aren’t resolvable publically. It all depends on configuration, such as reverse ns entries, zone accessibility, etc.

          You can have (sub)domains that are listed in the certificate lists and yet aren’t resolvable externally as well.

          • BonkTheAnnoyed@lemmy.blahaj.zone
            link
            fedilink
            English
            arrow-up
            0
            ·
            edit-2
            16 days ago

            Actually, wait. Something you a said might actually be just what I’m looking for: you mean that I can have DNS entry for mydomain.com and no additional CNAMEs, and have a cert for nextcloud.mydomain.com (or wildcard maybe?) and somehow still be able to use name based virtual servers?

            Hmmm. I thought I was going to be limited to path-based.

            Explain more?

            • wildbus8979@sh.itjust.works
              link
              fedilink
              English
              arrow-up
              1
              ·
              edit-2
              15 days ago

              Absolutely. Simply use ACME with the DNS validation method. Using bind you’ll want to create keys and allow TXT access for those keys to the validation domains. Fear not, this isn’t exclusive to bind, ACME tools supports dozens of other backends. That’s all you need the actual domain doesn’t need to be resolvable with an A/CNAME record. Internally you can run an entirely different DNS server to resolve your hosts, use hosts files, or use bind zones.