# This is a very simple / naive configuration for nginx + Davis
#
# USE HTTPS IN PRODUCTION
#

upstream docker-davis {
    server davis:9000;
}

server {
    listen 80;
    access_log off;

    root /var/www/davis/public/;
    index index.php;

    rewrite ^/.well-known/caldav /dav/ redirect;
    rewrite ^/.well-known/carddav /dav/ redirect;

    charset utf-8;

    location ~ /(\.ht) {
        deny all;
        return 404;
    }

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

    location ~ ^(.+\.php)(.*)$ {
        try_files       $fastcgi_script_name =404;
        include         fastcgi_params;
        fastcgi_pass    docker-davis;
        fastcgi_param   SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param   PATH_INFO        $fastcgi_path_info;
        fastcgi_split_path_info  ^(.+\.php)(.*)$;
    }
}
