@tflidd: Thank you very much for your reply. I looked at the log and here is what’s happening when I try to set up an account using my Mac.
For these tests, I have strictly apply the doc, that is: creating the .htaccess in /var/www/html with the following content
Redirect 301 /.well-known/carddav /nextcloud/remote.php/dav
Redirect 301 /.well-known/caldav /nextcloud/remote.php/dav
and using https://servername.com as “Server Address” (in Mac dialog box)
Here is what is happening in the different logs (when I try to set up a CalDAV account on my Mac):
/var/log/apache2/access.log :
CLIENT_IP - - [29/Oct/2016:18:54:09 +0200] "PROPFIND /.well-known/caldav HTTP/1.1" 301 3665 "-" "Mac+OS+X/10.12 (16A323) accountsd/113"
CLIENT_IP - - [29/Oct/2016:18:54:09 +0200] "PROPFIND /.well-known/caldav HTTP/1.1" 301 3665 "-" "Mac+OS+X/10.12 (16A323) accountsd/113"
CLIENT_IP - - [29/Oct/2016:18:54:09 +0200] "PROPFIND /nextcloud/remote.php/dav HTTP/1.1" 401 1717 "-" "Mac+OS+X/10.12 (16A323) accountsd/113"
CLIENT_IP - - [29/Oct/2016:18:54:19 +0200] "PROPFIND / HTTP/1.1" 405 734 "-" "Mac+OS+X/10.12 (16A323) accountsd/113"
CLIENT_IP - - [29/Oct/2016:18:54:19 +0200] "PROPFIND /caldav/v2 HTTP/1.1" 405 605 "-" "Mac+OS+X/10.12 (16A323) accountsd/113"
CLIENT_IP - - [29/Oct/2016:18:54:19 +0200] "PROPFIND /principals/users/USERNAME/ HTTP/1.1" 405 618 "-" "Mac+OS+X/10.12 (16A323) accountsd/113"
CLIENT_IP - - [29/Oct/2016:18:54:19 +0200] "PROPFIND /principals/ HTTP/1.1" 405 607 "-" "Mac+OS+X/10.12 (16A323) accountsd/113"
CLIENT_IP - - [29/Oct/2016:18:54:19 +0200] "PROPFIND /dav/principals/ HTTP/1.1" 405 611 "-" "Mac+OS+X/10.12 (16A323) accountsd/113"
CLIENT_IP - USERNAME [29/Oct/2016:18:54:09 +0200] "PROPFIND /nextcloud/remote.php/dav HTTP/1.1" 207 2287 "-" "Mac+OS+X/10.12 (16A323) accountsd/113"
/nextcloud_data/nextcloud.log :
{"reqId":"WBTUMX8AAQEAADQ4S@MAAAAA","remoteAddr":"CLIENT_IP","app":"webdav","message":"Exception: {\"Message\":\"HTTP\\\/1.1 401 No 'Authorization: Basic' header found. Either the client didn't send one, or the server is mis-configured, No 'Authorization: Basic' header found. Either the client didn't send one, or the server is mis-configured\",\"Exception\":\"Sabre\\\\DAV\\\\Exception\\\\NotAuthenticated\",\"Code\":0,\"Trace\":\"#0 [internal function]: Sabre\\\\DAV\\\\Auth\\\\Plugin->beforeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#1 \\\/var\\\/www\\\/nextcloud\\\/3rdparty\\\/sabre\\\/event\\\/lib\\\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\\n#2 \\\/var\\\/www\\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(446): Sabre\\\\Event\\\\EventEmitter->emit('beforeMethod', Array)\\n#3 \\\/var\\\/www\\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(248): Sabre\\\\DAV\\\\Server->invokeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#4 \\\/var\\\/www\\\/nextcloud\\\/apps\\\/dav\\\/lib\\\/Server.php(184): Sabre\\\\DAV\\\\Server->exec()\\n#5 \\\/var\\\/www\\\/nextcloud\\\/apps\\\/dav\\\/appinfo\\\/v2\\\/remote.php(30): OCA\\\\DAV\\\\Server->exec()\\n#6 \\\/var\\\/www\\\/nextcloud\\\/remote.php(165): require_once('\\\/var\\\/www\\\/nextcl...')\\n#7 {main}\",\"File\":\"\\\/var\\\/www\\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Auth\\\/Plugin.php\",\"Line\":188,\"User\":false}","level":0,"time":"2016-10-29T16:54:09+00:00","method":"PROPFIND","url":"\/nextcloud\/remote.php\/dav","user":"--"}
{"reqId":"WBTUMX8AAQEAADQ4S@QAAAAA","remoteAddr":"CLIENT_IP","app":"admin_audit","message":"Login attempt: \"USERNAME\"","level":1,"time":"2016-10-29T16:54:35+00:00","method":"PROPFIND","url":"\/nextcloud\/remote.php\/dav","user":"--"}
{"reqId":"WBTUMX8AAQEAADQ4S@QAAAAA","remoteAddr":"CLIENT_IP","app":"admin_audit","message":"Login successful: \"USERNAME\"","level":1,"time":"2016-10-29T16:54:35+00:00","method":"PROPFIND","url":"\/nextcloud\/remote.php\/dav","user":"USERNAME"}
/var/log/apache2/modsec_audit.log :
--46da5e14-A--
[29/Oct/2016:18:54:19 +0200] WBTUO38AAQEAACvnl@IAAAAM CLIENT_IP 50469 SERVER_IP 443
--46da5e14-B--
PROPFIND /dav/principals/ HTTP/1.1
Host: SERVER_NAME.com
Content-Type: text/xml
Depth: 0
Brief: t
Accept: */*
Connection: keep-alive
Prefer: return=minimal
User-Agent: Mac+OS+X/10.12 (16A323) accountsd/113
Content-Length: 181
Accept-Language: en-gb
Accept-Encoding: gzip, deflate
--46da5e14-F--
HTTP/1.1 405 Method Not Allowed
Strict-Transport-Security: max-age=15768000; includeSubDomains; preload
Allow: GET,HEAD,POST,OPTIONS
Content-Length: 241
Keep-Alive: timeout=5, max=96
Connection: Keep-Alive
Content-Type: text/html; charset=iso-8859-1
--46da5e14-E--
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>405 Method Not Allowed</title>
</head><body>
<h1>Method Not Allowed</h1>
<p>The requested method PROPFIND is not allowed for the URL /dav/principals/.</p>
</body></html>
--46da5e14-H--
Stopwatch: 1477760059807114 2758 (- - -)
Stopwatch2: 1477760059807114 2758; combined=64, p1=42, p2=15, p3=1, p4=0, p5=6, sr=0, sw=0, l=0, gc=0
Response-Body-Transformed: Dechunked
Producer: ModSecurity for Apache/2.9.0 (http://www.modsecurity.org/).
Server: Apache
Engine-Mode: "ENABLED"
--46da5e14-Z--
/var/log/apache2/error.log :
[Sat Oct 29 19:03:39.658666 2016] [autoindex:error] [pid 10358] [client CLIENT_IP:50837] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive
[Sat Oct 29 19:03:42.678102 2016] [autoindex:error] [pid 10191] [client CLIENT_IP 0:50838] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive
It seems that the problem is coming from modsec but I’m not really sure how to solve it…