If your site is at the root of the domain (something like http://www.example.com), find the location / block inside the configuration file, and add the following line to it.
try_files $uri $uri/ /index.php?$args;
Here, Nginx checks for the existence of a file at the URL ($uri), then for a directory ($uri/). If it doesn’t find a directory or a file, it performs an internal redirect to /index.php passing the query string arguments as parameters.
It should look like this after the edits :
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
If your site is in a subfolder (say /site), you’ll have to add an extra location /site/ block to your configuration file :
location /site/ {
try_files $uri $uri/ /site/index.php?$args;
}
After you have finished making the changes in the configuration file, reload the nginx configuration by :
nginx -s reload
WordPress’ pretty permalinks should work fine now.
I found this answer here
And here are some other helpful likns-