Use Nextcloud in LAN and WAN


I have a question about using Nextcloud in LAN as well as WAN. Currently my nextcloud is exposed to the internet and everything works so far. But when im in the same LAN as my Nextcloud server it still gets redirected though the internet. Meaning, when I try to access is mapped to the local ip address of the server) it gets redirected to Is there a way to use it locally so it doesn’t exit my LAN? Currently because of this my speeds are bottle necked because it goes through my isp.



You could probably configure your web server to accept connections for domain as well instead of redirecting to the “default” external address.
You probably need to server blocks (with the same content) in your web server config then.
And the internal domain needs to be added to the nextcloud config.php as trusted domains.

Hope this gives an idea and hopefully helps.

Thanks for the reply!
Do you mean with web server my reverse proxy or still the nextcloud installation? Also in the config.php my local ip address is under trusted domains and when i try to access it(eg. it still redirects to my public domain.

As @Schmu wrote, you can use a different FQDN to access your server on your LAN or you need to set-up a local DNS which resolves the FQDN of your server to a local ip address.

But how do I do that. I tried to add a trusted domain in the conifg.php file but it still redirects both and to which is my public domain.

That has absolutely nothing to do with Nextcloud itself and need to be done in your network environment. This mechanism is called a" Split DNS" setup. How this can be implemented is e.g. discussed here.

But then I dont get why redirects me to my public domain. When I try to sync my nextcloud to my pc I dont want it to go through the internet when the server is literally 1 meter next to me. Is there really no way to stop the redirects?

Usually your internet router is providing a lightweight DNS service on your LAN, which means most of the requests are forwarded to an internet DNS where the fqdn of your server is resolved to the external ip of your router.
Unfortunately most of the internet routers cannot route traffic correctly back to the LAN if an external ip address has been resolved.

A local dns server is the way to go. If you have an open router that is able to configure the dns then I’d use that or stand up a pi-hope and use that. I do this exact setup at home and all my web apps are setup with FQDN and some of them are only accessed by the local lab. When I am on my internal network nothing touches the WAN that I don’t want it too.

My solution:
Clone the Apache vhost in which I have configured my domain and rename the name and alias. Example --> minextcloud.local. Then add this to config file trusted domains array.
Later, I have modified the hosts file of my client machine. For convenience I use the free software “hosts file editor”. I have created a new entry to point to the local ip of the server I have tried to access it from the browser and it works. I tried to install the netcloud client and connect to ninjacloud.local. It flies!
Now I can connect from (outside) and from minextcloud.local (Lan)

1 Like