I made a fresh install of WordPress in a new directory and made a separate server section in nginx.conf for it.
I tired what you suggested, but to no avail. There's a small change which is that I don't get a 404 error any more and the page is displayed. My guess is that it's a different problem present in my original WordPress installation which is not present in the new one.
The problem with the pretty permalinks still remains however.
For example the WordPress sample page can have either of these two permalinks, depending on if permalinks are set to default or something else:
http://wptest.dev/?page_id=2 (default permalink setting)
http://wptest.dev/index.php/sample-page/ (any other permalink setting)
My server section in nginx.conf looks like this following your suggestion:
server {
listen 80;
server_name wptest.dev;
root /var/www/localhost/wptest;
index index.php;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
expires max;
}
location ~ \.php$ {
expires off;
try_files $uri =404;
include fastcgi_params;
fastcgi_pass localhost:65500;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
}