Forum

nextcloud setup

Pierre
14 September 2016, 14:13
Hi everybody!

As I got very useful help here before with OctoberCMS and Nibbleblog (discontinued) and wasn't able to get help on the nextcloud IRC and Forum as well as I was unable to find anything about nextcloud here, I am returning to this forum for some help.

I have running Arch Linux with PHP 7.0, MariaDB 10.1 and Hiawatha 10.3 and am trying to setup nextcloud on that machine. The command line installation finished successfully.
After that you get a nextcloud generated message that the domain ist not trusted and has to be added to the trusted domains array within the config.php file. I did as told.
But then, if I want to access the installed cloud instance again it now redirects from a files.domain.tld to https://files.domain.tld/index.php/login as before but displays a '404 Not Found' error message generated by Hiawatha.

So my suggestion is that there might be rewrite rules required for a functional nextcloud instance. Or at least it seems to be related to some other mistake within my configuration.

My configuration of Hiawatha so far is quite minimal.
Beside some other domains I have this one added for my nextcloud instance:
VirtualHost { # nextcloud
Hostname = files.domain.tld
WebsiteRoot = /srv/http/files.domain.tld/nextcloud
StartFile = index.html
AccessLogfile = /srv/http/files.domain.tld/log/access.log
ErrorLogfile = /srv/http/files.domain.tld/log/error.log
TLScertFile = /srv/http/files.domain.tld/tls_cert/files.pem
RequireTLS = yes
ExecuteCGI = yes
TimeForCGI = 5
}


With a way older version of ownCloud a few years ago this config worked quite well.

Does anyone have a clue what is going wrong here?
Hugo Leisink
14 September 2016, 14:33
What are the required rewrite rules for Apache?
Pierre
14 September 2016, 14:53
The rewrite rules in the .htaccess file are as follows:
  RewriteEngine on
RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteRule ^\.well-known/host-meta /public.php?service=host-meta [QSA,L]
RewriteRule ^\.well-known/host-meta\.json /public.php?service=host-meta-json [QSA,L]
RewriteRule ^\.well-known/carddav /remote.php/dav/ [R=301,L]
RewriteRule ^\.well-known/caldav /remote.php/dav/ [R=301,L]
RewriteRule ^remote/(.*) remote.php [QSA,L]
RewriteRule ^(?:build|tests|config|lib|3rdparty|templates)/.* - [R=404,L]
RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/.*
RewriteRule ^(?:\.|autotest|occ|issue|indie|db_|console).* - [R=404,L]


But they are only used if the rewrite module is available. So it should work without but doesn't at the moment.
Pierre
14 September 2016, 15:30
Found something for the nginx configuration that might apply in some way or another for hiawatha, too, at: https://docs.nextcloud.com/server/10/admin_manual/installation/nginx_examples.html#javascript-js-or-css-css-files-not-served-properly
Hugo Leisink
15 September 2016, 11:56
Try this one:
VirtualHost {
...
UseToolkit = nextcloud
HTTPAuthToCGI = yes
}

UrlToolkit {
ToolkitID = nextcloud
Match ^/\.well-known/host-meta(\?(.*))? Rewrite /public.php?service=host-meta&$2
Match ^/\.well-known/host-meta\.json(\?(.*))? Rewrite /public.php?service=host-meta-json&$2
Match ^/\.well-known/carddav Rewrite /remote.php/dav/
Match ^/\.well-known/caldav Rewrite /remote.php/dav/
Match ^/remote/([^?]*)(\?.*)? Rewrite /remote.php$2
Match ^/(?:build|tests|config|lib|3rdparty|templates)/.* DenyAccess
Match ^/.well-known/acme-challenge/.* Return
Match ^/(?:\.|autotest|occ|issue|indie|db_|console).* DenyAccess
}
Pierre
15 September 2016, 16:27
I had not enough time to make a full test of all functionality yet, but with a change it is now possible to login.

My UrlToolkit looks like this now:
UrlToolkit {
ToolkitID = nextcloud
Match ^/\.well-known/host-meta(\?(.*))? Rewrite /public.php?service=host-meta&$2
Match ^/\.well-known/host-meta\.json(\?(.*))? Rewrite /public.php?service=host-meta-json&$2
Match ^/\.well-known/carddav Rewrite /remote.php/dav/
Match ^/\.well-known/caldav Rewrite /remote.php/dav/
Match ^/remote/([^?]*)(\?.*)? Rewrite /remote.php$2
Match ^/index.php/([^?]*)(\?.*)? Rewrite /index.php$2
#Match ^/(?:build|tests|config|lib|3rdparty|templates)/.* DenyAccess
Match ^/.well-known/acme-challenge/.* Return
#Match ^/(?:\.|autotest|occ|issue|indie|db_|console).* DenyAccess
}


Both commented lines are throwing syntax errors. I added the rewrite rule for index.php which finally made it work.

Thanks a lot for your help once again!
Pierre
20 September 2016, 16:21
Just for documentation purposes:
When testing the nextcloud instance I realized that no files were shown in the web app and connection via WebDAV was not possible. I found a solution for that.

I added
WebDAVapp = yes

and
EnablePathInfo = yes

to virtual host settings.

Now everything seems to be running fine!
This topic has been closed.