Disable Access through untrusted domain

Hi, thanks for the reply. I’m pretty new to linux so I don’t know how to get the logs for Nextcloud. when I do “occ config:system:get trusted_domains” this is the output "No command 'occ' found, but there are 20 similar ones occ: command not found root1@ubuntu:~$:"
Thanks!

I accidentally replied by editing my post. Please see it again.

I did try the command again and nothing seemed to change. But, for some reason when I added the ip 192.168.1.* it disabled the untrusted domain page. But it no longer works.

This is what turns up when I run the command

localhost

192.168.1.*

That looks like it should.

The logs are probably the only way to determine the next course of action. I am not familiar with your installation method, but I’ll give it one shot. First attempt to access the server, verifying it shows the unwanted verify domain prompt, then run tail -n 20 followed by the file name returned by this command:

locate nextcloud.log

When I run tail -n 20 it seems to “break” the terminal I have to logout and log back in to get it to come back.

Heres whats happening

Yes, it should be followed by the filename. Pressing control-c would have worked to stop the command too. I see the locate command returned nothing.

Example of another way, since this is more sure to work:

Command: sudo nextcloud.occ config:system:get datadirectory
Returns: /var/www/nextcloud/data
Add /nextcloud.log to get the command

Command: tail /var/www/nextcloud/data/nextcloud.log

I’m not sure if I am doing something wrong

Capture4

Your sudo command was right. The tail command needs to have the specific output from the command because I don’t know where it is to tell you right off the bat.

Alright, I’ll give it a go.

It just shows alot of stuff now

moteAddr":“IP Address”,“user”:"–",“app”:“core”,“method”:“GET”,“url”:"/",“message”:“Trusted domain error. “IP” tried to access using “IP” as host.”,“userAgent”:“Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36”,“version”:“13.0.4.0”}

I think I get it. You want to disable the authorized domain for every possible value? There are probably good reasons not to do that, but simply replacing the IP address with a star in the command you put in the first post would work. I tested it.

When I do that I don’t think it works, also, it wont let me delete the other IPs that I have

I just tested a command like this would work:

sudo nextcloud.occ config:system:set trusted_domains 1 --value=*

When I run the :get trusted_domains command, it shows the star. I put a random host name in /etc/hosts for the server IP, accessed it by the name, and it didn’t complain. I then removed * from trusted domains and it complained normally.

Doing this is pretty unnecessary, and lets your server resources be used without your consent for whatever doesn’t require authorization.

To delete all your trusted domains at once, run:

sudo nextcloud.occ config:system:set trusted_domains
Hmm, this makes more sense but I didn’t try:
sudo nextcloud.occ config:system:delete trusted_domains

That will delete all your trusted domains at once. All of them, for real.

Well, I want to be able to access it whenever I’m not on my wifi, like my data connection (I believe the IP for that always changes) also I have to login with my username and password anyway. When I ran the clear domains command and then the star domain it added it but no change. Do I need to restart the server?

No, it seems to be consulted for every request. You need to run the command with the star exactly as written. Can you paste what you ran?

On my system, this will replace all trusted domains with *; here’s the text output.

root@andy-virtual-machine:/var/www/nextcloud# sudo -u www-data ./occ config:system:delete trusted_domains
System config value trusted_domains deleted
root@andy-virtual-machine:/var/www/nextcloud# sudo -u www-data ./occ config:system:set trusted_domains 0 --value=*
System config value trusted_domains => 0 set to string *
root@andy-virtual-machine:/var/www/nextcloud# sudo -u www-data ./occ config:system:get trusted_domains
*

The command with the star has to be done in that certain way that has “–value=*” or else.

The trusted domain is about the name you call the nextcloud server, nothing necessary about IP addresses of either the client or server. For the client, it doesn’t matter. Im going to assume the server is running at home on a mostly static IP.

You can use a free dynamic dns service to give your server a domain name, and that’s the only, single, trusted domain you need. Or you might need to access it from wifi from its ip address, which would make it require only two trusted domains total. But most routers will make it work without having to do that.

Heres what I did root1@ubuntu:~$ sudo nextcloud.occ config:system:set trusted_domains 1 --value=*System config value trusted_domains => 1 set to string *
root1@ubuntu:~$ sudo nextcloud.occ config:system:get trusted_domains
*
root1@ubuntu:~$
root1@ubuntu:~$

I don’t think that you can put a wildcard here. Why do you need to change your server’s ip? Most routers should allow to set a static IP even with DHCP (you can tell to set the same IP address for a given MAC address).

For external access (when dynamic ip’s come into the game), use hostnames like longcat proposed (with dynamic dns services like no-ip.com, you can resolve a static hostname to your current local ip). There are several services, I would verify that you take a service that allows you to use certificates from letsencrypt.

Well, I’m trying to remove this screen and I can get to this page when I’m not on my wifi. Before I some how disabled it but I wanted to disable SSL for whatever reason but then the screen came back. Even after I re-enabled SSL