server {
  listen 80 default_server;
  listen [::]:80 default_server ipv6only=on;

  root /var/www;
  index index.php index.html;

  # Make site accessible from http://localhost/
  server_name localhost;

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

  location /api {
    if (!-e $request_filename) {
      rewrite ^(.*)$ /api/api.php last; break;
    }
  }

  location /api/taskboard.db {
    rewrite ^(.*)$ /api/api.php last; break;
  }

  location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_index index.php;
    include fastcgi_params;
  }
}