Configuring web server

If you specify ActiveServer hostname (e.g. sync.domain.com) when configuring your email client, the client will actually access the server via URL of the following kind:

sync.domain.com/Microsoft-Server-ActiveSync

So it's important to reconfigure web server so that such URL is redirected to index.php file of your ActiveServer installation.

Below, we provide configuration samples for Apache and nginx webservers. The samples are highly-detailed, but their core item is setting up alias for /Microsoft-Server-ActiveSync.

Apache configuration

# Z-Push - ActiveSync over-the-air - default Apache configuration
<IfModule mod_alias.c>
    Alias /Microsoft-Server-ActiveSync /usr/share/z-push/index.php
</IfModule>
<Directory /usr/share/z-push>
    # Don't list a directory index, follow symlinks (maybe state dir is somewhere linked)
    DirectoryIndex index.php
    Options -Indexes +FollowSymLinks
    # Security
    # Don't allow .htaccess Overrides, disallow access to files
    AllowOverride none
    <IfModule !mod_authz_core.c>
        Order allow,deny
        allow from all
    </IfModule>
    <IfModule mod_authz_core.c>
        Require all granted
    </IfModule>
    <Files "config.php">
      <IfModule !mod_authz_core.c>
        Deny from All
      </IfModule>
      <IfModule mod_authz_core.c>
        Require all denied
      </IfModule>
    </Files>
</Directory>

Nginx configuration

server {
    server_name localhost; # Put your server name
    # Uncomment the following lines to enable SSL support if not configured yet
    #listen 443 ssl;
    #listen [::]:443 ssl;
    #ssl on;
    #ssl_certificate     /path/to/ssl.crt; # Put in the correct path
    #ssl_certificate_key /path/to/ssl.key; # Put in the correct path
    # If you're using PHP-FPM uncomment the following lines.
    #include         fastcgi_params;
    #fastcgi_index   index.php;
    #fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
    #fastcgi_param   REQUEST_URI $1;
    #fastcgi_param   PHP_FLAG "magic_quotes_gpc=off \n register_globals=off \n magic_quotes_runtime=off \n short_open_tag=on";
    #fastcgi_param   PHP_VALUE "post_max_size=20M \n upload_max_filesize=20M \n max_execution_time=3660";
    #fastcgi_param   HTTP_PROXY ""; # Mitigate https://httpoxy.org/ vulnerabilities
    #fastcgi_read_timeout 3660; # Z-Push Ping might run 3600s, but to be safe
    location ~* /Microsoft-Server-ActiveSync {
        alias       /usr/share/z-push/index.php;
        access_log  /var/log/nginx/z-push-access.log;
        error_log   /var/log/nginx/z-push-error.log;
        # Attachments ca 15MB max (since binary data needs to be base64 encoded in mine, which results in in about 33% overhead)
        client_max_body_size 20m;
        client_body_buffer_size 128k;
        # Select one of the fastcgi_pass values or adapt to your configuration
        #fastcgi_pass    unix:/var/run/php5-fpm.sock; # for PHP 5.X Debian/Ubuntu
        #fastcgi_pass    unix:/var/run/php/php7.0-fpm.sock; # for PHP 7.X Debian/Ubuntu
        #fastcgi_pass    unix:/var/run/php-fpm/php-fpm.sock; # usually RedHat and its derivatives
        #fastcgi_pass    127.0.0.1:9000; # default php-fpm config
    }
}