Nginx Rewrite Issue

EE = 3.3.8 Site created with --mysql option.

I am having an issue with a rewrite. It is conflicting with parameter setup by EE.

locations.conf

   location ~* \.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|swf)$ {
      add_header "Access-Control-Allow-Origin" "*";
      access_log off;
      log_not_found off;
      expires max;
    }

I have created a new conf file in the /var/www/site1.com/conf/nginx/rewrite.conf. I have confirmed the conf file is being pulled in. The following rewrite rules are not working due to the .css at the end of the file name.

location /files {
rewrite ^/files/master\.([0-9]+)?\.css$ /min/?g=css&456 break;
rewrite ^/files/master\.([0-9]+)?\.js$ /min/?g=js&456 break;
rewrite ^/files/second\.([0-9]+)?\.js$ /min/?g=jsa&456 break;
}

I am getting the same result with any file extension if it is listed in the cache static files options. I can change the .css to .htm in the rewrite rule and it works well.

What am I missing in the cache static files that is preventing a rewrite from being performed at a later config setting?

thank you.

After much gnashing of teeth, I ended up changing the redirects to a try_files parameter. The parameters must be higher in the conf file than the static cache file.

location ~ ^/files/master\.([0-9]+)?\.css$ {
    try_files $uri /min/?g=css&456;
}   
location ~ ^/files/master\.([0-9]+)?\.js$ {
    try_files $uri /min/?g=js&456;
} 
location ~ ^/files/second\.([0-9]+)?\.js$ {
    try_files $uri /min/?g=jsa&456;
} 

This will allow me to run the minify toolset and perform image processing tasks.