I donāt know if i post this now in the right place, but some of the Admins could move the topic, if they want. Iām relative new to Nextcloud, so please forgive e, if made some mistakes in my description, but i would do my best to describe the things.
My goal was it, to have a private Cloud, including Protocols like CalDAV, CardDAV, IMAP and also Exchange ActiveSync, since im coming from a Windows World and have have used Outlook.com since a very long time. All my setup is done on a small Raspberry Pi 2 with Raspbian installed. I use a āMiniban Imageā, since i use this Box only as a Server. You should have a Nextcloud installed up and running. As a Webserver, i use Nginx with PHP-FPM. For Nextcloud, i have installed additionally MariaDB as a MySQL Backend. Currently Nextcloud is installed as a Subdirectory under Webroot. This will change later. Its planned to move the installation to the Webroot of a Subdomain of my DynDNS Setup.
To get ActiveSync to work, i use Z-Push. I have used this before with a Zarafa/Kopano Installation and like it very much. Z-Push does not only work with Zarafa/Kopano, it also works with other Backendās to. It can work with BackendIMAP, BackendCalDAV, BackendCardDAV and other i didnāt remember now. Best of all, there is a BackendCombinded, which allow it to combine several Backends. In my case, i use BackendCombined, to combine BackendIMAP for Mails via IMAP, BackendCalDAV for the Calendars and Tasks and BackendCardDAV for Contacts. Since they are combined, i have only one possibility to enter User Credentials and it is a Multi-User-Thing -> All Backends must share exactly the same Credentials.
Since i tried the Installation, i have setup first every Backend for itself, to have a better insight, where are Problems and what is working. I started with BackendIMAP to get my Mails to work. For this, you must install first Z-Push. You can download it via wget from http://download.z-push.org/final/. For example you can use
wget http://download.z-push.org/final/2.3/z-push-2.3.3.tar.gz
After this, you should unpack the archive to the directory /usr/share/ and rename the resulting folder to āz-pushā. Make this folder owned by your webserveruser with āchown -R www-data:www-data /usr/share/z-pushā
Now you can edit the file /usr/share/z-push/config.php. Later i will call this file āGlobal Configā, since there are config.php files for every Backend. First change the Timezone to your Timezone. In my case i use
define('TIMEZONE', 'Europe/Berlin');
If you must Login to your IMAP Server with full E-Mail Address, set
define('USE_FULLEMAIL_FOR_LOGIN', true);
Now specify two directory for state and logfiles:
define('STATE_DIR', '/var/lib/z-push/'); define('LOGFILEDIR', '/var/log/z-push/');
Both directorys must be writeable by the webserveruser. As next you define the used Backend. For this first test, we would like to use IMAP and so we use
define('BACKEND_PROVIDER', 'BackendIMAP');
For now, you can ignore the rest of the Global Config file and save your changes. Do not forget to allow write access for the state and log file directory.
As next configure the BackendIMAP. For this, edit the file /usr/share/z-push/backend/imap/config.php. Here change the Server to the Server you would like to use. Ask your Mail Provider for the correct values. In my case, i must enter the server address, the port 993 and as option i use only ā/tlsā. If /tls did not work, try /ssl. You can try to determine the settings from your IMAP Server, if you connect via telnet to it.
Now have a look at the IMAP folder settings in config.php for IMAP, to set the correct folders. In my case, i must change some folder names, maybe its needed in your case to. You could look at the foldernames via telnet or any normal IMAP Client. You could try also the Webmail from Nextcloud or the Rainloop App. In my case, i use Rainloop.
Its now time to change your nginx config. You must add a new location in your virtual server directive to set the Alias directory for /Microsoft-Server-ActiveSync as described in the readme from Z-Push for Apache. Itās a little bit more in nginx and i dont know if my Config is the best for this, but it works. So lets define such a location:
location /Microsoft-Server-ActiveSync {
root /usr/share/z-push/;
add_header Strict-Transport-Security max-age=63072000;
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
I set here a timeout with 300, because the first sync (and sometimes syncs in future) could take a long time on our small Raspberry Pi. With this, you would see the timeout error not so often as with other settings, because its time enough to make a Sync. You should also change the timeout setting in your php.ini for fpm, to get no timeouts.
Now you could try to setup a first test on your Client Device. I use a Android Phone with the App āNineā and the Windows Mail App. Both can use EAS. For the first tests, its good to have some Logfile on the Screen running, For this i open multiple Putty Windows or one Putty Window with some āscreenā-Sessions. So i have a look at the Error and Access Logs of nginx and Z-Push. In my case it starts directly with some missing PHP Libraries. I had to install the following modules: libawl-php, php-gettext, php5-curl, php5-gd, php5-imap, php5-json, php5-mcrypt, php5-mysql (since i save my STATES in MariaDB), php5-readline and php5-xsl. After installing the missing modules, the sync of E-Mails should work fine. Maybe it needs some time, if you have a lot of Mails.
If the Mails are working you can look at the Calendar Data. For this to make work, you should change first the correct Backend. In my case this is BackendCalDAV. Open /usr/share/z-push/backend/caldav/config.php and change the needed settings:
define('CALDAV_PROTOCOL', 'https');
define('CALDAV_SERVER', 'your.domain.net');
define('CALDAV_PORT', '443');
define('CALDAV_PATH', '/nextcloud/remote.php/dav/calendars/%u/'); //if nextcloud is installed in a subfolder
define('CALDAV_PERSONAL', 'personal');
define('CALDAV_SUPPORTS_SYNC', true);
define('CALDAV_MAX_SYNC_PERIOD', 2147483647);
Change this to your server and if your installation is in other directory, change also the path. Im not sure, if CalDAV of NextCloud does support Sync, but i thinks so. Someone shoud correct this, if im wrong.
Next, change the Backend in the Global Config to BackendCalDAV instead of BackendIMAP and start a fresh Sync. Your Calendars should then appear on your Device.
Attention: If you use the Standard EAS on a Samsung Device, you see only one Calendar! Sometimes this is a merge of all your Calendars on the Server and sometimes its only the Maincalendar (the one which comes first). This is a problem of the Samsung EAS Implementation. I dont know, if this also the Case with the GMail App, since i havent used this before. With the App āNineā, all is OK and you have all your Calendars andā¦ Tata!!! ā¦Tasksā¦
If Calendar and Mails do work, you could have a look at the Contacts. First change the config in /usr/share/z-push/backend/carddav/config.php:
define('CARDDAV_PROTOCOL', 'https');
define('CARDDAV_SERVER', 'your.domain.net');
define('CARDDAV_PORT', '443');
define('CARDDAV_PATH', '/nextcloud/remote.php/dav/addressbooks/users/%u/contacts/');
define('CARDDAV_DEFAULT_PATH', '/nextcloud/remote.php/dav/addressbooks/users/%u/contacts/');
define('CARDDAV_GAL_MIN_LENGTH', 5);
define('CARDDAV_CONTACTS_FOLDER_NAME', '%u Addressbook');
define('CARDDAV_SUPPORTS_SYNC', true);
define('CARDDAV_SUPPORTS_FN_SEARCH', false);
define('CARDDAV_URL_VCARD_EXTENSION', '.vcf');
Its nearby the same as for CalDAV, also here, please change your path and server do your needs. After this, change the Backend in the Global Config from BackendCalDAV to BackendCardDAV and restart the Sync. Only one Adressbook is synced, if you have more than one Adressbook, you could only sync he first one.
If Sync of Contacts do also work, you should edit /usr/share/z-push/backend/combined/config.php.
First change the array of available Bankends to your backends, like this:
'backends' => array(
'i' => array(
'name' => 'BackendIMAP',
),
'c' => array(
'name' => 'BackendCalDAV',
),
'd' => array(
'name' => 'BackendCardDAV',
),
),
and map the folders to the correct Backend as in my example:
'folderbackend' => array(
SYNC_FOLDER_TYPE_INBOX => 'i',
SYNC_FOLDER_TYPE_DRAFTS => 'i',
SYNC_FOLDER_TYPE_WASTEBASKET => 'i',
SYNC_FOLDER_TYPE_SENTMAIL => 'i',
SYNC_FOLDER_TYPE_OUTBOX => 'i',
SYNC_FOLDER_TYPE_TASK => 'c',
SYNC_FOLDER_TYPE_APPOINTMENT => 'c',
SYNC_FOLDER_TYPE_CONTACT => 'd',
SYNC_FOLDER_TYPE_NOTE => 'c',
SYNC_FOLDER_TYPE_JOURNAL => 'c',
SYNC_FOLDER_TYPE_OTHER => 'i',
SYNC_FOLDER_TYPE_USER_MAIL => 'i',
SYNC_FOLDER_TYPE_USER_APPOINTMENT => 'c',
SYNC_FOLDER_TYPE_USER_CONTACT => 'd',
SYNC_FOLDER_TYPE_USER_TASK => 'c',
SYNC_FOLDER_TYPE_USER_JOURNAL => 'c',
SYNC_FOLDER_TYPE_USER_NOTE => 'c',
SYNC_FOLDER_TYPE_UNKNOWN => 'i',
),
If this is done, change the Backend in the Global Config from BackenCalDAV to BaeckendCombined. After this, resync you device and you should have Mails, Calendars and Contacts synced.