server {
        listen       80;
        server_name  wiki.wojciechkozlowski.eu;

        root /usr/share/nginx/html;
        index index.php index.html index.htm;

        location / {
                index doku.php;
                try_files $uri $uri/ @dokuwiki;
        }

        location @dokuwiki {
            rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last;
            rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last;
            rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last;
            rewrite ^/(.*) /doku.php?id=$1 last;
        }

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_pass unix:/run/php/php7.0-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }

        location ~ /(data|conf|bin|inc)/ {
                deny all;
        }
}