Nginx webserver with regex location and alias and xls extension

nginxweb-server

i have a nginx configuration something like this,

server {
    server_name my.domain.com;
    listen 80;
    root /path/to/http/root;
    include /path/to/proxy.common.conf;

    location ~ ^/foo-(.+)$ {
        alias /path/to/static/file/$1;
    }
    location / {
        try_files $uri $uri/ =404;
        proxy_pass http://127.0.0.1:8000/;
    }
}

i'm unable to access the files with location /foo-something.xls, it always returns 404 not found…

i also tried with .xlsx, .doc, and .docx but it also shows not found…

if i access file like .js, .css, .png, .xls1, .doc1, etc, it behaves normally…

the error log shows the location with regex did not match, and tried to look at the root location…

i also tested the location with

location = /foo-test1.xls
location ^~ /foo-test2.xls

and alias to a file, and it returns the file content…

am i missing something with my configuration?

i just found this problem when developing a report generator module on my company's framework…

i also tried to read at both nginx source and pcre source, but i can't find any string that related to those extensions…

Best Answer

i found what causes the confusion with the path...

i missed at checking at the proxy.common.conf...

after rechecking, i found there's a location to check files with those extension with regex...

that's why the regex stop searching after finding matched location...

after cross checking with someone who configured the nginx before, the location have something to do with our previous framework...

thanks for your support...