Open menu

How to get Nextcloud from both home and the net


You get Nextcloud, you get Nextcloud, I have Nextcloud

So you have installed Nextcloud, you have setup your router to NAT to it. You have a domain pointed at it, but you now can't see it at home.

This seems to be a common problem, I see it on Reddit almost once a week. The bit your missing is DNS, I know what your thinking. I have that setup, it works from the internet. You have public DNS setup, good job! But you now need to look at how your internal DNS works, this is the bit that not documented.

Here's the issue you have, when your phone or laptop or what ever wants to connect to your Nextcloud server. It looks up what IP address it has, this is done with DNS (Domain Name System). This will return your public IP address, out on the net that's fine. As you are external to your router, you get connected. But when at home, some routers don't allow you to connect to the public IP address of your router from the inside (hairpin NAT).

So how do you solve this? Well your own DNS server is how, that's how I have my network setup. The bad news, some routers don't allow you to set a custom DNS server. To solve this your going to need a DHCP server, don't worry as my solution will have both!

Pi-hole (maybe DHCP)

The quickest way to get a DNS server running is with pi-hole, an added benefit of pi-hole is it blocks ads as well. Also it can run a DHCP server if you need that.

Im not going to tell you how to install it, as there are very good documents on it. Follow the install, either with docker or a full install. If you need DHCP this will help

Now the magic

Once you have pi-hole installed and working for all your devices, you might not notice that any apps on your phone now don't show any ads. That's because pi-hole didn't tell your phone how to find all the ad sites, you didn't even download the ad let alone see it!

Now goto http://pi.hole/admin/ and login, the password is what you set when you installed it. On the left menu, find Local DNS records and click it. This is how you tell pi-hole that nextcloud is at your internal IP, not the public IP. If all went to plan, you should now see your nextcloud on the domain you setup.

If your looking for a more complex DNS setup checkout my Pi-hole custom config