server { listen 80; server_name domain.com; root /var/www/domain.com; index index.php index.html; log_not_found off; charset utf-8; error_log /var/log/nginx/domain.com-error.log; location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } location ~ /\.ht { deny all; } location ^~ /data { deny all; return 404; } rewrite ^/.well-known/carddav /index.php/dav/ redirect; location ~ ^(.+\.php)(.*)$ { include fastcgi_params; fastcgi_split_path_info ^(.+\.php)(/[^?]*).*$; fastcgi_pass 127.0.0.1:9000; # fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; } } # optional server { listen 80; server_name dav.domain.com; rewrite ^/.well-known/carddav / redirect; root /var/www/domain.com; index index.php index.html; log_not_found off; charset utf-8; error_log /var/log/nginx/dav.domain.com-error.log; location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } location ~ /\.ht { deny all; } rewrite ^/.well-known/carddav / redirect; rewrite ^(.*)$ /index.php/dav$1 last; location ~ ^(.+\.php)(.*)$ { include fastcgi_params; fastcgi_split_path_info ^(.+\.php)(/[^?]*).*$; fastcgi_pass 127.0.0.1:9000; # fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; } }