0

I was wondering if someone could point me to the right direction, currently have NGINX working with rainloop using SSL letsencrypt works great. now im trying to get the Active Sync with zpush working. I got it working by taking down the rainloop, my question is how can i have rainloop and zpush on the same config with 2 roots? i was looking at the manual and saw alias but not sure if i did it correctly this is what i got so far.

Rainloop and zpush (what i think should be configured)

 server {
server_name mail.mydomain.com;
root /var/www/rainloop/;
access_log /var/www/rainloop/logs/access.log;
error_log /var/www/rainloop/logs/error.log;
index index.php;

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

location ~ \.php$ {
    fastcgi_index index.php;
    fastcgi_split_path_info ^(.+\.php)(.*)$;
    fastcgi_keep_conn on;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

location ~ /\.ht {
    deny all;
}

location ^~ /data {
  deny all;
}


location ^~ /zpush {
    alias /var/www/zpush;
    index index.php;

    try_files $uri $uri/ /zpush/index.php;
}

location /Microsoft-Server-ActiveSync {
    rewrite ^(.*)$  /index.php last;
}


listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/mail.mydomain.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/mail.mydomain.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


ssl_trusted_certificate /etc/letsencrypt/live/mail.mydomain.com/chain.pem; # managed by Certbot
ssl_stapling on; # managed by Certbot
ssl_stapling_verify on; # managed by Certbot

  }

   server {

   if ($host = mail.mydomain.com) {
    return 301 https://$host$request_uri;
 } # managed by Certbot


server_name mail.mydomain.com;
listen 80;
return 404; # managed by Certbot


   }

 # HTTP TO HTTPS REDIRECT
 server {
  listen 80;
  server_name mail.mydomain.com;
return 301 https://$host$request_uri;
}

and this is my zpush which i tried to put inside of rainloop but had no luck

server {
listen 443;
server_name mail.mydomain.com autodiscover.mydomain.com;

ssl on;
ssl_certificate         /etc/letsencrypt/live/mail.mydomain.com/fullchain.pem;
ssl_certificate_key     /etc/letsencrypt/live/mail.mydomain.com/privkey.pem;

#root    /usr/share/www;
root    /var/www/zpush;
index   index.php;

error_log /var/log/nginx/zpush-error.log;
access_log /var/log/nginx/zpush-access.log;

location / {
    try_files $uri $uri/ index.php;
}

location /Microsoft-Server-ActiveSync {
    rewrite ^(.*)$  /index.php last;
}



location ~ .php$ {
    include /etc/nginx/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;
    # Z-Push Ping command will be alive for 470s, but be safe
    fastcgi_read_timeout 630;
  }

 }

Thank you

killmasta93
  • 21
  • 1
  • 5
  • Looking at your first example, your `alias` should work, but `root /var/www;` is more efficient. You will need a nested location within `location ^~ /zpush` for `.php` URIs, see [this answer](https://serverfault.com/questions/778329/nginx-php-in-a-subdirectory/778336#778336). – Richard Smith Sep 05 '18 at 09:30
  • Thanks for the reply so i edited what you said by adding the location php section This is what i got https://pastebin.com/aH4ac5YU but no luck to get the active sync but when i put on the zpush config only without the rainloop it works – killmasta93 Sep 06 '18 at 04:11
  • Your `root` is probably wrong, unless you mean for the pathname to the files to have `zroot` in the path twice. Try `root /var/www;` in the `location ^~ /zpush` block, so the files are located in the `/var/www/zpush` directory. See [this document](http://nginx.org/en/docs/http/ngx_http_core_module.html#root). – Richard Smith Sep 06 '18 at 11:01
  • Thanks for the reply added the root /var/www; but still no luck hmmm so odd maybe im missing something? – killmasta93 Sep 07 '18 at 01:04

0 Answers0