How to access NextCloud from outside and from inside my LAN

Hello,

I have installed Nextcloud 22.2.0 on Ubuntu Server 21.04 on a Raspberry Pi 4 with 8 GB of RAM.
I am using Duck DNS as DDNS.

On my Android phone, I have set up the NextCloud application with a URL like “mycloud.duckdns.org”. This means that when I am outside my network (LAN), I can connect to NextCloud on my RPI because “mycloud.duckdns.org” refers to the local IP address of my Raspberry Pi.
But when I connect my Android to my local network via WiFi, I can’t reach NextCloud.
When I’m connected to WiFi, “mycloud.duckdns.org” leads me to my router’s private IP address and not to my RPI’s.
This causes a problem when I want to synchronise large files such as photos.
Apparently, I can’t register the same user account twice with two different addresses (one for when I’m outside; the other for when I want to use my WiFi.

What should I do?

Search Hairpinning or NAT Loopback for your router.

Thank you @devnull !
I enabled NAT loopback and it solved the problem.

Now when I installed NextCloud, I followed a couple of video tutorials, where it was suggested to buy a domain name in order to secure a valid SSL certificate.
But I didn’t manage to set it up.
The goal is to have a secure connection with - for example - https://cloud.mydomain.com that would point to my NextCloud setup.

Do you have any idea how to manage this?

Have you purchased a domain?

Hello @ just,

Yes, I have purchased a domain name already.
I redirected cloud.mydomain.com to mycloud.duckdns.org. But it’s not what I am supposed to do, is it?

I have asked some help to the registrar company where I bought the domain, but the sent me back to NextCloud.

Who is your registrar? Do they have documentation for DNS? You’ll need to setup a subdomain

You can set up a CNAME record, it just says that cloud.mydomain.com should resolve the same like mycloud.duckdns.org.

@just
I bought my domain name at gandi.net.
Here is the documentation : https://docs.gandi.net/en/domain_names/index.html.

Thank you for your help @tflidd .

I am studying now to learn what a CNAME record is and how to set it up.
I don’t understand what kind of information I should input in order to have cloud.mydomain.com resolve like mycloud.duckdns.org.
For duckdns.org, I installed a script on my Ubuntu Server so the only information I have from Duck DNS is a token.

In the documentation of the registrar, I found something about LiveDNS:
https://docs.gandi.net/en/domain_names/common_operations/changing_nameservers.html.

Is it what I need?

You have to create a CNAME record for cloud.mydomain.com pointing to mycloud.duckdns.org (https://docs.gandi.net/en/domain_names/faq/record_types/cname_record.html#cname-records), as far as I understand the documentation, you have to put a point in the end of the subdomain you want to redirect: mycloud.duckdns.org.

Yes, that is the same like the duckdns service and you can do this directly without going through duckdns. Not sure if their API is compatible with the software that you currently use.

The CNAME will certainly be faster and easier to implement. If you can do this directly with gandi without passing through duckdns is certainly a cleaner solution. I’d try that for a different subdomain first, and if it is working, you can switch the CNAME record to this method.

Thank you @tflidd !
Yes, it would be great if I could do everything with Gandi.net. without using DuckDNS.

So far I have managed to create a CNAME record so that I can access NextCloud with http://cloud.mydomain.com. And it’s not a web redirection.
So, we’re progressing !
Now, there are still a few questions:

  1. I don’t know how to change the settings on my Android NextCloud and DAVx5 apps (because now I don’t need to use mycloud.duckns.org anymore, do I?).
    Do I have to uninstall the apps and install them back again?
  2. Now Gandi.net sent me the link to this script:
    https://github.com/rmarchant/gandi-ddns
    and its documentation:
    https://api.gandi.net/docs/livedns/ .
    So I am studying this. It should allow me to by-pass Duckdns.

That is a new question, please make a new topic. I don’t know if Android clients and DAVx5 support redirects and update the URL.

OK. I will look. Someone might already have met the same issue.