Nginx Config

From Davical
Jump to: navigation, search

General Note

DAViCal is not a web application, in the sense of something like Drupal, Joomla, Flickr or Facebook. Rather, it is an HTTP application, needing full access to various header information passed to the webserver by the CalDAV client software.

Many web application stacks tend to assume that applications will only use GET and POST methods, for example, whereas DAViCal needs to receive the full request data for many other http methods including PUT, MOVE, PROPFIND, PROPPATCH, REPORT, MKCOL, MKCALENDAR and more.

As a result you may have increasing difficulty getting more obscure parts of DAViCal's functionality to work with FastCGI, such as creating calendars from within CalDAV client software.

Virtual Host Installation

You will need a running PHP FastCGI server on port 12345. This is not covered here, but since you are an nginx and PHP user, you most probably already know how to run it.

server {
       listen 80;
       server_name davical.example.net;

       access_log /var/log/nginx/davical.access_log main;
       error_log  /var/log/nginx/davical.error_log  warn;

       root    /usr/share/davical/htdocs;
       index   index.php index.html;

       keepalive_timeout 0;

       location /images/ {
       }

       location ~ \.php {
               include /etc/nginx/fastcgi_params;
               fastcgi_param   SCRIPT_FILENAME  $document_root$fastcgi_script_name;
               fastcgi_pass    127.0.0.1:12345;
               fastcgi_index index.php;
       }
}

I had problems with the above config. This worked for me under nginx 0.7.61. -- blake

server {
       listen 80;
       server_name davical.example.net;

       access_log /var/log/nginx/davical.access_log;
       error_log  /var/log/nginx/davical.error_log;

       root    /usr/share/davical/htdocs;
       index   index.php index.html;

       keepalive_timeout 0;

       location /images/ {
       }

       location ~ ^(.+\.php)(.*)$ {
               include fastcgi_params;
               fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
               fastcgi_pass 127.0.0.1:12345;
                       
               fastcgi_split_path_info ^(.+\.php)(.*)$;
               fastcgi_param PATH_INFO $fastcgi_path_info;
               fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;

               fastcgi_read_timeout 180;
               fastcgi_buffers 4 256k;
               fastcgi_buffer_size 128k;
               }

       location ~ \.php {
               include /etc/nginx/fastcgi_params;
               fastcgi_param   SCRIPT_FILENAME  $document_root$fastcgi_script_name;
               fastcgi_pass    127.0.0.1:12345;
               fastcgi_index index.php;
       }
}

To get DAViCal and NGINX working with iCal 6.0 clients, it's been reported that the following should be added to your configuration, similarly to the other location blocks:

       location / {
               return 301 /caldav.php$1;
       }

HTTPS for nginx on Ubuntu 14.04

####  serveur  davical
server {
	server_name davical.xxxxxx.com;
	root    /usr/share/davical/htdocs;
	index index.html index.htm index.php index.pl;
# begin : https section
	listen 443;
	ssl on;
	ssl_certificate /etc/ssl/certs/tol-cacert.pem;
	ssl_certificate_key /etc/ssl/private/tol-cacert.key;
	ssl_session_timeout 5m;
	ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
	ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
	ssl_prefer_server_ciphers on;
# end : https section
	keepalive_timeout 0;
	location /images/ {
	}
	location / {
	        try_files $uri $uri/ =404;
	}
	location ~ ^(.+\.php)(.*)$ {
	include fastcgi_params;
	        fastcgi_param SCRIPT_FILENAME 
$document_root$fastcgi_script_name;
	        fastcgi_pass   unix:/tmp/php.socket;

	        fastcgi_split_path_info ^(.+\.php)(.*)$;
	        fastcgi_param PATH_INFO $fastcgi_path_info;
	        fastcgi_param PATH_TRANSLATED 
$document_root$fastcgi_path_info;

	        fastcgi_read_timeout 180;
	        fastcgi_buffers 4 256k;
	        fastcgi_buffer_size 128k;
	}

	location ~ \.php$ {
	        fastcgi_pass   unix:/tmp/php.socket;
	        fastcgi_index  index.php;
	        fastcgi_param  SCRIPT_FILENAME 
$document_root$fastcgi_script_name;
	        include /etc/nginx/fastcgi_params;
	}

}

nginx with php-fpm:

add this to the php-fpm pool configuration:
php_value[include_path] = /www/php_include/awl/inc
php_value[magic_quotes_gpc] = 0
php_value[register_globals] = 0
php_value[error_reporting] = "E_ALL & ~E_NOTICE"
php_value[default_charset] = "utf-8"