Nextcloud does not start

Hello,

I am trying to test out nextcloud locally, however when I follow the wiki:
https://nixos.wiki/wiki/Nextcloud

I don’t have a firewall on my nix since I am using openWRT as router.

I get this error when I go to port http://192.168.10.2:80 i get:

Access through untrusted domain Please contact your administrator. If you are an administrator, edit the “trusted_domains” setting in config/config.php like the example in config.sample.php.

This is my code:

environment.etc."nextcloud-admin-pass".text = "XXXXXXXXXXXXXXX";
services.nextcloud = {
  enable = true;
  package = pkgs.nextcloud27;
  hostName = "nixos";
  config.adminpassFile = "/etc/nextcloud-admin-pass";

# config.dbtype = "pgsql"; 
  database.createLocally = true;
};

As the error message said, I suspect you need to add

config.trustedProxies = ["127.0.0.1"];
2 Likes

The option to configure that is a nextcloud option. This is the option I found is services.nextcloud.config.extraTrustedDomains. It takes a list of strings.

Trying but still not working.

Found this similar issue but not able to fix it:
https://www.reddit.com/r/NixOS/comments/110life/nextcloud_trusted_domains_not_working/

services.nextcloud = {
  enable = true;
  package = pkgs.nextcloud27;  
  hostName = "nixos";
#   https = true;
  config.adminpassFile = "/etc/nextcloud-admin-pass";
  config.trustedProxies = ["127.0.0.1"];
  config.extraTrustedDomains = ["miarete.lan"];

# config.dbtype = "pgsql"; 
  database.createLocally = true;
};

image

If you use the IP address to access this host, surely nextcloud is correctly complaining that the domain is wrong?

1 Like

Yes it works:

  config.extraTrustedDomains = ["192.168.10.2"];

THANKS!!!

1 Like

I am wondering the following:

  1. its possible to handle password inside the package without have to add the password in: config.adminpassFile = “/etc/nextcloud-admin-pass”;
  2. is it possible to define a custom path where photos and docs will be stored?

Thanks

John

How exactly would you like to set the admin password if not with that option? That option will only set it when the service is initially installed, so if you want to change it later you need to/can do so via the nextcloud UI.

You can change the full directory with services.nextcloud.datadir.

I would not recommend this personally, /var/lib is the standard for storing application data, and there’s no real good reason to move the nextcloud directory out of it (except maybe if you are messing with disks being mounted in various places, but it would be far more reasonable to mount such to /var/lib/nextcloud directly instead of moving the nextcloud install folder).

If you want to do this because you want to back up data, or access it from your user or something along those lines, figure out proper group permissions instead, and/or use a privileged ExecStartPre to prepare the directory for backing up.

Nextcloud will probably make this difficult, those directories are not intended to be browsed without their UI, if you do so anyway and end up modifying anything there’s a pretty good chance you’ll screw up your database.

If you want a directory that behaves like a normal directory but is shared between devices, consider using syncthing instead.