Redirect to server local ip

Dear Community,

I am having problems with a fresh nextcloud install on my dietpi odroid N2. Everything is working fine when i try to access the cloud locally.

Also I can access it remotely but only via the nextcloud client app for android.

When trying to access the cloud remotely in browser via the public ip, it redirects me to the local ip of the server which in turn produces an error.

ssh is working as well. the apache error log is empty. any ideas?

what is the content of your nextcloud/config/config.php file?
you can use for example pastebin.com or hastebin.com for a config paste

I just had a look at my config.php and found the following line:

'overwrite.cli.url' => 'http://localhost/nextcloud'

I changed it to:

'overwrite.cli.url' => 'http://*my-servers-ip*//nextcloud'

Yea, that’s the issue

It isnt yet working sadly. Restarted the browser from which I am trying to access. Still the same issue.

Do I maybe have to restart nextcloud or so for the changes to take effect?

In this post they say I dont…

*edit:

I just found this issue on github about overwrite.cli.url being broken. Changing my config.php accordingly also didnt help.

Strangely I cant even access the apache servers root: http://*my-server-ip*/ isnt available as well.

You still haven’t posted any log or config file. It’s only a guessing game like this

You are lucky that I like games :video_game: :smile:

Is this correctly configured in your config.php?

'trusted_domains' =>
  array (
    0 => '*my-servers-ip*',
  ), 

Haha, I am actually quite new to this forum and have never used pastebin before… Still trying to figure out how to embed it in my post here.

here’s my config:

<?php
$CONFIG = array (
  'passwordsalt' => '...',
  'secret' => '...',
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => '*',
  ),
  'datadirectory' => '/mnt/dietpi_userdata/nextcloud_data',
  'dbtype' => 'mysql',
  'version' => '16.0.1.1',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'filelocking.enabled' => true,
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '/run/redis/redis-server.sock',
    'port' => 0,
  ),
  #'overwrite.cli.url' => 'http://*my-server-ip*/nextcloud',
  'overwritehost' => '*my-server-ip*/nextcloud', 'overwriteprotocol' => 'https'
  'htaccess.RewriteBase' => '/nextcloud',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'oc_admin',
  'dbpassword' => '...',
  'installed' => true,
  'instanceid' => '...',
  'maintenance' => false,
);

Should I leave localhost there and just add my-server-ip or replace it?

im not sure if this works like that. Did you put this line 1 => '*', yourself in it? It usually is enough to just enter your server ip there…

You can just overwrite localhost with your server ip
Dont delete the 1 => '*' line for now. I don’t know if thats of any use. It probably is there to trust any domain. But still to be safe, just type in your server ip into the 0 => position

No, I didn’t put it there… should I delete it?

#'overwrite.cli.url' => 'http://*my-server-ip*/nextcloud',

Remove the hashtag so that it is:
'overwrite.cli.url' => 'http://*my-server-ip*/nextcloud',

Still nothing changed…

I made the following changes:

0 => '*my-servers-ip*'
#0 => 'localhost'
1 => `*`
#2 => '*my-servers-ip*' 

and

'overwrite.cli.url' => 'http://*my-server-ip*/nextcloud',
#'overwritehost' => '*my-server-ip*/nextcloud', 'overwriteprotocol' => 'https'

is that alright?

how can I amke the changes take effect?

  • There shouldnt be any # in your config. Lines beginning with a # will be ignored.
  • changes should take effect immediately

Yes, I did add these # just to make clear what isn’t in my config…

okay, my bad. I thought overwritehost should remain enabled

Could it be something with the apache2.conf?

Just because I think I should be able to visit http://*my-server-ip* at least…

I am not too familiar with apache, sorry… I think apache doesn’t check for where the communication is coming from. So I actually dont think that is the problem…

Maybe try to connect to your server with https:// or with http:// ?

I did configure apache to forward all http requests to port 443. I just checked it now and it is working as expected. so every http ip I access gets changed to https in the browsers address bar.

Maybe something is wrong with my certificates…
I will try to disable http to https forwarding and access via http.

oh you have it via https! Maybe
'overwrite.cli.url' => 'http://*my-server-ip*/nextcloud', in your config.php should be changed to https then too.

If that doesnt work, try disabling the RedirectMatch in your apache config and connect without ssl. Maybe that will bring you closer to the solution. Also check for other RedirectMatch or Redirect directives in your apache config

1 Like

Okey, so I found the error.

It was the https redirect in the apache Virtual Host file /etc/apache2/sites-enabled/000-default.conf:

Redirect "/" "https://local-server-ip"

But that of course is wrong if I am not in the same network as the router.

I changed that line in my virtual host file to:

Redirect "/" "https://public-server-ip"

That did it. I will now play around a little with all the changes that we did in the course of this conversation and post my findings.

Thanks for all the help @Gee858eeG !!!

*edit:

after playing around a bit i found:
nextcloud config.php works with the following entries:

'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => '*my-server-ip*',
  ),

and

'overwrite.cli.url' => 'https://localhost/nextcloud',
2 Likes