How to NOT redirect to public ip when in LAN

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com 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:

example

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

longer
example
here

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 ‘mydoamin.duckdns.org’, 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 ‘mydoamin.duckdns.org’, 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!):

<?php
$CONFIG = array (
.
.
.
  'trusted_domains' => 
  array (
    0 => 'ip_for_unraid_server:444',
    1 => 'mydoamin.duckdns.org',
  ),
  'dbtype' => 'mysql',
  'version' => '16.0.1.1',
  'trusted_proxies' => ['letsencrypt'],
  'overwritehost' => 'mydoamin.duckdns.org',
  'overwriteprotocol' => 'https',
  'overwrite.cli.url' => 'https://mydoamin.duckdns.org',
  'dbname' => 'nextcloud',
.
.
.
);

If you have a fancy Internet router, you could put a DNS entry on that pointing mydoamin.duckdns.org to your internal IP, or run a DNS server on your Unraid server and use this for your LAN’s DNS resolution (also resolving mydoamin.duckdns.org 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 mydomain.duckdns.org to the desired IP address in your hosts file.

1 Like

Hi,

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:
/etc/hosts

For Windows:
C:\Windows\system32\drivers\web\etc\hosts

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

192.168.1.100    mydoamin.duckdns.org

… 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…

[INTERNET]
|
[ROUTER 192.168.10.1] - DHCP Left As Is - DNS Set To Ubuntu Server IP — [LAN Clients - Get IP Range 192.168.10.10 - .253, DNS Set To 192.168.10.2, Domain set to duckdns.org]
|
[UBUNTU SERVER - 192.168.10.2 ] - NextCloud Install - BIND DNS Install with Domain duckdns.org with A entry for yourdomain.duckdns.org pointing to 192.168.10.2 - 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 duckdns.org 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: