Getting Nextcloud to work with Mac OS X adress book

Yes, right, my url after login into my cloud is https://subdomain.domain.tld/index.php/apps/files/ - rewrite rules? Crazy, I get exhausted about how complicated the setup of owncloud/nextcloud on a webhoster is…

I just checked, right now, my .htacess looks like this:

#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####
RewriteEngine On
RewriteBase /
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
ErrorDocument 403 //core/templates/403.php
ErrorDocument 404 //core/templates/404.php

Header always set Strict-Transport-Security "max-age=15768000; includeSubDomains; preload"

But I have another .htacess from a former owncloud installation which did contain much more stuff.

Should I just copy that into the .htacess for the nextloud installation or do you see anything wierd or anything what doesnt work? Thanks

<IfModule mod_headers.c>

  <IfModule mod_env.c>
    Header always set X-Content-Type-Options "nosniff"
    Header always set X-XSS-Protection "1; mode=block"
    Header always set X-Robots-Tag "none"
    Header always set X-Frame-Options "SAMEORIGIN"
    Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains; preload"

    # Add security and privacy related headers
    #Header set X-Content-Type-Options "nosniff"
    #Header set X-XSS-Protection "1; mode=block"
    #Header set X-Robots-Tag "none"
    #Header set X-Frame-Options "SAMEORIGIN"
    #Header set X-Download-Options "noopen"
    #Header set X-Permitted-Cross-Domain-Policies "none"
    #SetEnv modHeadersAvailable true
  </IfModule>

  <IfModule mod_setenvif.c>
    <IfModule mod_fcgid.c>
       SetEnvIfNoCase ^Authorization$ "(.+)" XAUTHORIZATION=$1
       RequestHeader set XAuthorization %{XAUTHORIZATION}e env=XAUTHORIZATION
    </IfModule>
    <IfModule mod_proxy_fcgi.c>
       SetEnvIfNoCase Authorization "(.+)" HTTP_AUTHORIZATION=$1
    </IfModule>
  </IfModule>

  # Add cache control for CSS and JS files
  <FilesMatch "\.(css|js)$">
    Header set Cache-Control "max-age=7200, public"
  </FilesMatch>
</IfModule>
<IfModule mod_php5.c>
  php_value upload_max_filesize 2G
  php_value post_max_size 2G
  php_value memory_limit 512M
  php_value mbstring.func_overload 0
  php_value always_populate_raw_post_data -1
  php_value default_charset 'UTF-8'
  php_value output_buffering 0
  <IfModule mod_env.c>
    SetEnv htaccessWorking true
  </IfModule>
</IfModule>
<IfModule mod_php7.c>
  php_value upload_max_filesize 2G
  php_value post_max_size 2G
  php_value memory_limit 512M
  php_value mbstring.func_overload 0
  php_value default_charset 'UTF-8'
  php_value output_buffering 0
  <IfModule mod_env.c>
    SetEnv htaccessWorking true
  </IfModule>
</IfModule>
<IfModule mod_rewrite.c>
  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]

  # Rewrite rules for `front_controller_active`
  Options -MultiViews
  RewriteRule ^core/js/oc.js$ index.php [PT,E=PATH_INFO:$1]
  RewriteRule ^core/preview.png$ index.php [PT,E=PATH_INFO:$1]
  RewriteCond %{REQUEST_FILENAME} !\.(css|js|svg|gif|png|html|ttf|woff|ico|jpg|jpeg)$
  RewriteCond %{REQUEST_FILENAME} !core/img/favicon.ico$
  RewriteCond %{REQUEST_FILENAME} !/remote.php
  RewriteCond %{REQUEST_FILENAME} !/public.php
  RewriteCond %{REQUEST_FILENAME} !/cron.php
  RewriteCond %{REQUEST_FILENAME} !/core/ajax/update.php
  RewriteCond %{REQUEST_FILENAME} !/status.php
  RewriteCond %{REQUEST_FILENAME} !/ocs/v1.php
  RewriteCond %{REQUEST_FILENAME} !/ocs/v2.php
  RewriteCond %{REQUEST_FILENAME} !/updater/
  RewriteCond %{REQUEST_FILENAME} !/ocs-provider/
  RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/.*
</IfModule>
<IfModule mod_mime.c>
  AddType image/svg+xml svg svgz
  AddEncoding gzip svgz
</IfModule>
<IfModule mod_dir.c>
  DirectoryIndex index.php index.html
</IfModule>
AddDefaultCharset utf-8
Options -Indexes
<IfModule pagespeed_module>
  ModPagespeed Off
</IfModule>
#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####

ErrorDocument 403 /core/templates/403.php
ErrorDocument 404 /core/templates/404.php
<IfModule mod_rewrite.c>
  RewriteRule . index.php [PT,E=PATH_INFO:$1]
  RewriteBase /
  <IfModule mod_env.c>
    SetEnv front_controller_active true
    <IfModule mod_dir.c>
      DirectorySlash off
    </IfModule>
  </IfModule>
</IfModule>
Summary

This text will be hidden

At least, the .well-known rewrite rules will be worth a try. These helped some year ago for my apple usage.

Here’s .htaccess which goes with nextcloud for manual installation:

<IfModule mod_headers.c>
  <IfModule mod_setenvif.c>
    <IfModule mod_fcgid.c>
       SetEnvIfNoCase ^Authorization$ "(.+)" XAUTHORIZATION=$1
       RequestHeader set XAuthorization %{XAUTHORIZATION}e env=XAUTHORIZATION
    </IfModule>
    <IfModule mod_proxy_fcgi.c>
       SetEnvIfNoCase Authorization "(.+)" HTTP_AUTHORIZATION=$1
    </IfModule>
  </IfModule>

  <IfModule mod_env.c>
    # Add security and privacy related headers
    Header set X-Content-Type-Options "nosniff"
    Header set X-XSS-Protection "1; mode=block"
    Header set X-Robots-Tag "none"
    Header set X-Frame-Options "SAMEORIGIN"
    Header set X-Download-Options "noopen"
    Header set X-Permitted-Cross-Domain-Policies "none"
    SetEnv modHeadersAvailable true
  </IfModule>

  # Add cache control for CSS and JS files
  <FilesMatch "\.(css|js)$">
    Header set Cache-Control "max-age=7200, public"
  </FilesMatch>
</IfModule>
<IfModule mod_php5.c>
  php_value upload_max_filesize 20G
  php_value post_max_size 20G
  php_value memory_limit 512M
  php_value mbstring.func_overload 0
  php_value always_populate_raw_post_data -1
  php_value default_charset 'UTF-8'
  php_value output_buffering 0
  <IfModule mod_env.c>
    SetEnv htaccessWorking true
  </IfModule>
</IfModule>
<IfModule mod_php7.c>
  php_value upload_max_filesize 20G
  php_value post_max_size 20G
  php_value memory_limit 512M
  php_value mbstring.func_overload 0
  php_value default_charset 'UTF-8'
  php_value output_buffering 0
  <IfModule mod_env.c>
    SetEnv htaccessWorking true
  </IfModule>
</IfModule>
<IfModule mod_rewrite.c>
  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]
</IfModule>
<IfModule mod_mime.c>
  AddType image/svg+xml svg svgz
  AddEncoding gzip svgz
</IfModule>
<IfModule mod_dir.c>
  DirectoryIndex index.php index.html
</IfModule>
AddDefaultCharset utf-8
Options -Indexes
<IfModule pagespeed_module>
  ModPagespeed Off
</IfModule>
#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####

ErrorDocument 403 /core/templates/403.php
ErrorDocument 404 /core/templates/404.php

That seems to be identical to the one i found on an old installation above.

And it seems to be working! crazy!

Only thing left: now i get some error warnings about integrity check:

Results
=======
- core
	- INVALID_HASH
		- .htaccess
	- EXTRA_FILE
		- tmp/oc_tmp_nnmupN-folder/.htaccess
- files_external
	- INVALID_HASH
		- l10n/nl.js

Raw output
==========
Array
(
    [core] => Array
        (
            [INVALID_HASH] => Array
                (
                    [.htaccess] => Array
                        (
                            [expected] => 4a97aae4d05df89a28bf2e63fe2a31cdf2afe74d3c9f622a81d6b0f1f4e001639c7c3a31d7aaa793c00d5f355e0bfaad62ec45507245de44...etc.....
                            [current] => bcc50fb677192508c389d0425addf7e11289a17f39943......etc.....

try to change max upload size on nextcloud admin page, it will overwrite .htaccess file, and maybe will save it’s hash as valid(don’t really know how integrity check works)

1 Like

Well… strange things…

1st: changing the max upload size lead to a temporary dissappearance of the integrity warning - strangely enough after a few moments the warning came back. And i dont succed to get from a 1 GB limit back to a 2 GB limit…

2nd: whilst logging into the adress book account with Mac OS X went fine after the implementing the rewrite rules, i cant explain why but some adresses will just not sync? i got two machines, the first machine got two of my 4 test-adresses, the second machine doesnt get any adress, although it seems to be logged in the nextcloud-adressbook without any error message.

by the way, i found out i have a .htacess not only in my clouds root folder, but also one in my config folder. is it supposed to be there or could it be a source of trouble? it reads as follows:

# line below if for Apache 2.4
<ifModule mod_authz_core.c>
Require all denied
</ifModule>

# line below if for Apache 2.2
<ifModule !mod_authz_core.c>
deny from all
</ifModule>

# section for Apache 2.2 and 2.4
IndexIgnore *

it should be there, it denies access to config folder from web.
try to force update contacts on second machine, maybe it doesn’t trust to server cert, on reload it should show connection error.

Ok ,thanks!

Now gotta figure out why i can not change the upload limit from 1GB to 2 GB anymore, tried it several times, will not change…

If you replaced .htaccess, it have permissions of user who placed it, change it by chown to user which runs apache.

Having a working .htaccess is really important.

1- it makes disappeared the index.php in the URL

2- it integrates some quick conf for php max upload etc… Quite usefull

3- it have embedded the rewrite rules for caldav and webdav
When i started to use Owncloud this rules wasn’t there,
I have to type this on every client
Login : user
Password : password
Server : https://myserver.com/remote.php/dav/addressbooks/users/username/

Now the server is just : https://myserver.com/
As simple as adding an iCal server.

no one of these helped.

I managed to add Caldav using advanced option in macOS sierra however… CardDav and none of these (Cal or CardDav) worked.

I would really appreciate your help.

EDIT…

Ok Solved the problem.

Solved it how?

@ViViDboarder

Well Actually I used different methods for each App and device … here is what I did :

1- macOS :

CalDAV :
First Please Choose “Advanced” for “Account Type”

Then in “Server Address” please type your domain like "
DOMAIN.COM

And in “Server Path” type :
/NEXTCLOUD/remote.php/dav/principals/users/USERNAME/

Notes:

  • Please remove /nextcloud/ if your nextcloud is installed in root of your domain.
  • Do not forget to change USERNAME to your own NextCloud User

CardDAV:

I selected “Manual” for “Account Type” and entered server path as below :

https://EXAMPLE.COM:MY_SERVER_PORT/nextcloud/remote.php/dav/principals/users/USERNAME 

Notes :

  • Server port is usually SSL port (default : 443) but this value maybe different from server to server.
  • Please remove /nextcloud/ if your nextcloud is installed in root of your domain.
  • Do not forget to change USERNAME to your own NextCloud User

2- iOS

In iOS is actually very easy and kind of silly !!

First you should go through adding CalDAV and CardDAV as normal then after sometime it will give you an error just choose cancel and go to advanced (do not quite the whole process just cancel using NON-SSL version) and choose Using SSL (if you want to) and type in your SSL port (Usually 443 by default) and again click on next so it tries to verify the server and after sometime gives you the same error. So again click on cancel and then “SAVE”.

Despite the errors in this time this will work like a charm meaning the error is just wrong.

Note: I used the the Cal/CardDAV path from my NextCloud for the server path.

Note: In some cases this is not needed to set the port but in my case it did not work without setting the port.

I hope this helps :slight_smile:

Good luck and please keep us updated if this worked for you too.

1 Like

I’ve been having similar problems and just seen your response. I’ve got the calendar on OSX working but still cannot get it to work on IOS . What’s the entry that you have on the advanced settings in CalDav on IOS?

Mine reads http://MYDOMAIN.COM/nextcloud/remote.php/dav/principals/users/USERNAME/
The USE SSL is ‘selected’ and the Port Entry has 443

It all saves as you suggest, but the Nextcloud calendar is still not showing in calendar.

I still cannot get the contacts to work on IOS or OSX, but lets try and figure out one thing at a time.

It is just as follows :
http://MYDOMAIN.COM/nextcloud/remote.php/dav/principals/users/USERNAME/

One question, is your cloud installed in a sub-directory or in your domain root ?

Regarding the iOS Calendar, have you checked if your CalDAV is active in your calendar list ? ( located in Calendar > Calendars (on the bottom of the screen).

And Regarding the CardDAV in macOS, have you used the port which I provided in my previous reply which includes port in the server path ?

and please note that in macOS is would take sometime for your contacts to show up after you add your cardDAV

Well this is really inexplicable. I decided to remove all the entries on both the iPhone and iMac and re-entered the settings again for both CardDav and Caldav. After filling in all the initial settings and saving then, I then went back into the advanced settings and entered

https://MyDOMAIN.COM:443/nextcloud.remote.php/dav/principles/users/USERNAME

( By the way the above entry works for both CardDav and Caldav)

I then save these settings and then reboot the device and Bingo. When I open of contacts and calendar, everything shows.

When I go back to the advanced settings the entry I made above has now changed to

https://MyDOMAIN.COM/nextcloud.remote.php/dav/principles/users/USERNAME

and the USE SSL option is selected and 443 has been entered as the port number.

I cannot explain why this now works, where’s yesterday it didn’t.

Anyway, I’m now up and running on both IOS and OSX.

Thanks

Great to hear that its working for you and yeah I do understand what you say.

You know putting “:443” after the domain name is actually telling the iOS or Mac that my port is 443 (manually).

And by the way this really should not be like this and Apple has been able to solve this issue in last 10 years but for some reason they decided not to.

Anyways Again happy to hear that you finally sorted it out.

Good luck.

Hi,
I just used the pattern

https://MyDOMAIN.COM/remote.php/dav/principals/users/USERNAME/

on the “manual” dialog to add an addressbook.

WIth a Nextcloud installed to the root of the webserver/domain and it worked with macOS Sierra 10.12.4 addressbook.

Hope that helps someone to get it configured :wink: