Hi Vladimir,
in your first post I missed your part about the rewriting rule, rewrite ^(.*\.php)(/)(.*)$ $1?file=/$3 last;: please, get rid of it and go with the PATH_INFO plain support as described in the Moodle docs.
You can access https://moopi.mrverrall.co.uk/course/view.php?id=4: there you'll have a nice picture of the bits and pieces used to run a Moodle instance on a Raspberry Pi 2 via nginx.
HTH,
Matteo