How to NOT redirect to public ip when in LAN

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face: is for home/non-enterprise users. If you’re running a business, paid support can be accessed via where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:


Or for longer, use three backticks above and below the code snippet:


Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 12.0.2):Latest from linuxserver
Operating system and version (eg, Ubuntu 17.04): Unraid
Apache or nginx version (eg, Apache 2.4.25): Latest Nginx from linuxserver

The issue you are facing:

My issue is not a bug problem, I just can’t figure out how to make own cloud notice that I am on LAN. I followed Spaceinvader Ones tutorial and everything works fine. My only issue is next cloud will redirect me to use my domain name even if I am on my LAN. I know he sets it up like this, but after two hours of googling I can’t find a way around this. I could only find people with redirect problems.

More clearly. If I am outside of my home, when I enter ‘’, It works fine. But when I am home, and enter the lan_ip_for_unraid_server:NextCloudPort into my browser (or click on webGUI in docker menu) I get redirected to ‘’, with has a speed penalty(I tested). How would I make it use lan_ip_for_unraid_server:NextCloudPort when I am inside the same network.

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

$CONFIG = array (
  'trusted_domains' => 
  array (
    0 => 'ip_for_unraid_server:444',
    1 => '',
  'dbtype' => 'mysql',
  'version' => '',
  'trusted_proxies' => ['letsencrypt'],
  'overwritehost' => '',
  'overwriteprotocol' => 'https',
  'overwrite.cli.url' => '',
  'dbname' => 'nextcloud',

If you have a fancy Internet router, you could put a DNS entry on that pointing to your internal IP, or run a DNS server on your Unraid server and use this for your LAN’s DNS resolution (also resolving to your internal IP).

1 Like

…and if you don’t have a router that will let you do that, and aren’t willing or able to upgrade to one, you can always point to the desired IP address in your hosts file.

1 Like


Both previous speaker are correct. There is nothing to change in the Nextcloud configuration (on your server) and only in your local network - either on the client or the router.

The simplest solution is to make an entry to the hosts file on your client.
For Unix it is:

For Windows:

Simply add “THE_SERVER’S_IP” to your client’s hosts file, for example:

… All of which is great unless you have multiple devices trying to access this, or happen to be on a laptop which you take away.

I would suggest that yes. A good router that can do DNS is a bonus.

If not then split DNS is your friend. I noticed you are on Ubuntu. Perhaps set up BIND DNS on there as well (there’s loads of walk throughs, just Google BIND DNS Ubuntu).
Then tell your router to send out the the IP address and domain of your Ubuntu DNS Server instead of what ever it is using now so it would look something like…

[ROUTER] - DHCP Left As Is - DNS Set To Ubuntu Server IP — [LAN Clients - Get IP Range - .253, DNS Set To, Domain set to]
[UBUNTU SERVER - ] - NextCloud Install - BIND DNS Install with Domain with A entry for pointing to - Static IP Address

That’s what I’ve done and it works nicely with the only exception being that obviously anything to do with the actual domain will also need entries in the DNS just incase DNS forwarding doesn’t pick up on it needing to forward on.

Hope this makes sense. And I’m sure there’ll be lots of others with better solutions :slight_smile: