Z-Push with nginx centos 7

Hi Everyone,

I Just installed nginx and wanted to configure z-push for this. Allredeay had it working with httpd but nginx is faster. However i can not seem to get it working. I allredeay had zpush working but now i just installed package “z-push-config-nginx.noarch” I change the config file according to my settings but nginx wont redirect me to the login page? Seems the alias is not working in the file. Can anyone give me a hint on wath can be the problem?

Hi ckruijnthens,

Have you restarted nginx after making changes to the config files? Do you have apache and nginx running on the same system? Are there any errors in the nginx and Z-Push logs? Please post your nginx configuration.

Manfred

@manfred Hi Manfred,

Yes i restarted nginx. Apache is disabled at the moment. If i go to the zpush site i get redirected to the nginx welcome page?

When is use a config found on the internet it works:

server {

listen 443;

server_name mail.ckruijntjens.nl;
ssl on;
ssl_certificate /etc/letsencrypt/live/ckruijntjens.nl-0002/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/ckruijntjens.nl-0002/privkey.pem; # managed by Certbot

root /usr/share/z-push;

index index.php;

location / {

try_files $uri $uri/ index.php;

}

location /Microsoft-Server-ActiveSync {

rewrite ^(.*)$ /index.php last;

}

location ~ .php$ {

include fastcgi_params;

fastcgi_index index.php;

fastcgi_param HTTPS on;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

fastcgi_pass unix:/var/run/php5-fpm.sock;

}

When i use the config included in the package it wont work:

server {
server_name mail.ckruijntjens.nl; # 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     /etc/letsencrypt/live/ckruijntjens.nl-0002/fullchain.pem; # Put in the correct path
ssl_certificate_key /etc/letsencrypt/live/ckruijntjens.nl-0002/privkey.pem; # 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
}

location ~* /AutoDiscover/AutoDiscover.xml {
    alias       /usr/share/z-push/autodiscover/autodiscover.php;

    access_log  /var/log/nginx/z-push-autodiscover-access.log;
    error_log   /var/log/nginx/z-push-autodiscover-error.log;

    # 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

    fastcgi_index   autodiscover.php;
}

Hi ckruijnthens,

thank you for your feedback. Were there any errors in nginx log file when using the configuration from z-push-config-nginx package?

Manfred

@manfred Hi manfred No none

@manfred hi manfred am i forgetting something here>?it just wont work?

Hi ckruijnthens,

well, one has to make the changes to nginx config anyway in order to make it work and it worked in our internal test. However I’m not an nginx expert and if someone sees something obviously wrong or missing in the default config, please give us feedback and we will change it in the future Z-Push versions.

Manfred

To me the “alias” has never worked with centos7 and nginx, i could find “access denied” errors by tailing the z-push-error.log

It might be my configuration not properly done but i found better to have a “location” with a relative path and a fastcgi parameter with an absolute path (and fix manually some directory Permissions). I didn’t use any “rewrite”.

Just search this forum for nginx and you will find other posts on alternative nginx configurations.