Wordpress Single Installation In Subdirectory Sitemap Rewrite Rules Nginx

I have a single separate wordpress installation inside a subdirectory of another wordpress installation. Subdirectory’s name is “blog” (This is not a multisite setup). My rewrite rules for nginx are:

location ~ ([^/]*)sitemap(.*)\.x(m|s)l$ {
 rewrite ^/sitemap\.xml$ /sitemap_index.xml permanent;
  rewrite ^/([a-z]+)?-?sitemap\.xsl$ /index.php?xsl=$1 last;

  # Rules for yoast sitemap with wp|wpsubdir|wpsubdomain
  rewrite ^.*sitemap_index\.xml$ /index.php?sitemap=1 last;
  rewrite ^.*/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
}

Sitemap is generated for both example.com/sitemap_index.xml and example.com/blog/sitemap_index.xml but both are same and do not contain posts of the second installation in subdirectory(blog). I understand this is related to rewrite rules configuration of subfolder but I am not able to figure out what exactly the problem is. I am using Yoast plugin and have installed Yoast plugins on both the installations i.e root and subfolder separately.

Got this working by changing Yoast rewrite rules to below in wpcommon.conf

rewrite ^$dir1/sitemap\.xml$ $dir1/sitemap_index.xml permanent;
rewrite ^$dir1/([a-z]+)?-?sitemap\.xsl$ $dir1/index.php?xsl=$1 last;
rewrite ^$dir1.*sitemap_index\.xml$ $dir1/index.php?sitemap=1 last;
rewrite ^$dir1.*/([^/]+?)-sitemap([0-9]+)?\.xml$ $dir1/index.php sitemap=$1&sitemap_n=$2 last;