Post Name Permalink setup gives 404 error inside sub-directory

It’s happening because Nginx doesn’t interpret rewrite rules like Apache via mod_rewrite. You need to change your nginx vhost config file (nginx site config file, i.e /etc/nginx/sites-enabled/your-site-config.conf file)

Add the following line inside server block

location / {
            try_files $uri $uri/ /index.php?$args; 
}

if the location / is already present, then remove the existing try_files directive and replace it with the following line

try_files $uri $uri/ /index.php?$args;

Now restart or reload Nginx and your problem will be gone. Here is a good article link regarding this https://www.cyberciti.biz/faq/how-to-configure-nginx-for-wordpress-permalinks/