NGINX 配置2个根?

NGINX 配置2个根?

我想知道是否有人可以给我指明正确的方向,目前 NGINX 使用 SSL letsencrypt 与 rainloop 配合使用效果很好。现在我试图让 Active Sync 与 zpush 配合使用。我通过关闭 rainloop 让它工作,我的问题是如何在具有 2 个根的相同配置上让 rainloop 和 zpush 发挥作用?我看了手册,看到了别名,但不确定我是否做对了,这是我目前得到的结果。

Rainloop 和 zpush(我认为应该配置)

 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;
}

这是我的 zpush,我试图将其放入 rainloop 中,但没有成功

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;
  }

 }

谢谢

相关内容