Title: Nginx and php scripts that are using the path as argument
Date: 2017-06-20 13:00

I'm running a private [dokuwiki](https://www.dokuwiki.org) instance for various reasons,
and recently fell in love with the [davcal](https://www.dokuwiki.org/plugin:davcal) plugin,
that provides a good-looking and usable integration of a graphical calendar,
along with synchronisation,
either by acting as a [caldav](https://en.wikipedia.org/wiki/CalDAV) server,
or via an [ics](https://en.wikipedia.org/wiki/ICalendar) feed.

Unfortunately, its code features things like this in the `ics.php` file:

```bash
$path = explode('/', $_SERVER['REQUEST_URI']);
$icsFile = end($path);
```

So the path will look like `/ics.php/my_ics_file.ics`, and since my nginx is
configured to only pass (some) `.php` files to the php interepreter, it won't work.

Fortunately, I have a [friend](http://fr33tux.org) that knows nginx-fu;
and here is the trick to get it working:

```nginx
location ~ ^/lib/plugins/davcal/ics.php/(.*)$ {
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param REDIRECT_STATUS 200;
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
            
    fastcgi_split_path_info ^(.+\.php)(.*)$;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
}
```
