Combining LAN and Outside access

I have Owncloud installed and running on a RPi4 with port forwarding properly configured.

Expected behaviour

On my laptop I would like to be able to access the owncloud server with Gnome Online Accounts (for CalDav and CardDav) when the laptop is connected to the internet from outside the LAN and when the laptop is connected to the same LAN as the RPi

Actual behaviour

The laptop properly connects when I am outside the LAN because the online account is configured as https://public.ip:port/ownlcoud. This is set in Gnome Online Accounts using the DAV user/pass credentials.

The problem is when the laptop is connected to the LAN, the connection to the account is broken and the CalDav / CardDav communications are interrupted.

Server configuration

Operating system: Raspbian
Web server: nginx/1.14.2
Database: mysql
PHP version: 7.3.11-1
ownCloud version: 10.3.2.2

I’ve searched through the forum for a similar problem but all the posts I’ve found were from people who had difficulty accessing their OC server from outside their network. I’m having trouble accessing it from inside the network while keeping my device properly configured to keep accessing it while outside the network. Have I missed something in the configuration ?

Your router might not allow connection from the internal network to its external interface to be SNATed back into the internal network.
What you need is for the DNS server on your local network to resolve the FQDN of your ownCloud server with an internal IP address instead of the external one.
Perhaps your router already provides a feature that allows you to do that. Otherwise you might have to set up a DNS server for your network.

There might be other solutions to this problem, perhaps somebody else knows something :slight_smile:

2 Likes

Thanks, that seems like a plausible explanation.

I have checked in my router advanced config pages and there seems to be no feature that allows me to resolve the external address as an internal IP.

I might look into setting up a DNS server other than my router for the network unless someone has another idea.

Two quick tests:
Curl the external IP:port from within your network and see what response you get:

curl -I (-k https://)ext.ip.add.ress:port

And then, while you are still on your local network, set the DNS name in your host-file resolve to the local IP address.
On Linux you can find it in /etc/hosts where you just have to add a line like so:

192.168.xx.xx  owncloud.fqdn.tld
1 Like

Running curl -I ext.ip.add:port from within my network gives me this :

HTTP/1.1 400 Bad Request
Server: nginx/1.14.2
Date: Tue, 03 Mar 2020 16:30:59 GMT
Content-Type: text/html
Content-Length: 271
Connection: close

Incidentally my external IP was changed recently by my ISP and since then trying to (re)configure my online account on the laptop to connect to the OC server using the new external IP also yields me a 400 Bad Request from Gnome Online Accounts app.

I must have something configured wrong.

I’m familiar with /etc/hosts but how do i know my owncloud FQDN ?
Also, should the /etc/hosts file be modified on the raspbian running owncloud or on the laptop trying to connect to it ?

I see you are only accessing your ownCloud via IP. You’d need an FQDN, for example from some DynDNS provider, otherwise you can’t do the host-file setup.

You would have to only adjust the host file of your laptop.

1 Like

I set up DynDNS on my router using No-IP provider. It is properly configured and I have tested that it receives updates correctly by manually changing the IP to be 1.1.1.1 and then rebooting the router, which correctly re-configures the value to the proper IP.

However, if I edit my /etc/hosts file on my laptop to add the following line :

192.168.xx.xx    owncloud.fqdn.tld

(IP and FQDN are of course replaced by their proper values).

This breaks external access to the owncloud server.

Does it break all external access, or only on the laptop? It would make sense to do it on the laptop, as the FQDN always resolves to the IP provided in the hosts file.

In our company, I was able to setup an A record on our internal DNS server, to provide the internal IP address of the owncloud box for all requests within the network. This has proven to be the most reliable and problem free solution for us. It does however, require a DNS server capable of performing this function (perhaps you could set one up on the RPi, I wouldn’t expect you’ll have too much load on your local DNS server).

1 Like

The external access is only broken for the laptop when the line is active in the /etc/hosts file. As you say, this makes sense as it tries to resolve the FQDN as a local address which either isn’t attributed, or, if it is, is not the server i’m looking for when I’m outside my own LAN.

It seems the only way to solve the question I opened this thread with is to have a configurable DNS server on the LAN the owncloud server is running from that can point any device trying to connect to the server using the FQDN (required for external access) to the proper local IP 192.168.xx.xx.

I’ve never set up a DNS server, do you know of any good documentation on the subject that could be a starting point for the simple set-up I’m looking to implement ?

Obviously this breaks external access to the server for the laptop as it is a private IP address that won’t be routed on the internet.

I said that you should only run it as a test, whether this will allow you to fix the actual problem by setting up a DNS server on you network.

1 Like

Sorry, I’ve never setup a DNS server on a *nix system, only configured records in one on a Windows Server. My only advice is to remember to reconfigure your DHCP server to dish out the new DNS server IP to all your LAN clients.

Here is another user having a similar problem, where dnsmasq was recommended for the job.

So you might not need a full DNS server

1 Like

Yes I misunderstood that, my mistake.

Thanks for the link, I’ll look into it ! Thanks for your help on the subject too :slight_smile:

1 Like