0

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...

6
  • So you're saying that you can access /foo-file.xls1 but nut /foo-file.xls? Are the permissions the same (although that should give a 403).
    – Halfgaar
    Oct 7, 2013 at 10:26
  • yes, both locations are aliased to the same file... so the permission should be the same... Oct 7, 2013 at 14:29
  • And what does the nginx error log say? Just that it can't find /bla/bla/file.xls? If you copy paste that URL in a terminal after ls, it does find it then?
    – Halfgaar
    Oct 8, 2013 at 7:23
  • it searches inside the root directory... something like can't find /path/to/http/root/file.xls... obviously the file isn't there... can you reproduce the error? i found it the same on both our development and production server... Oct 8, 2013 at 15:08
  • The file isn't there? What is wrong with the path it's referencing? How does it differ from paths that do exist?
    – Halfgaar
    Oct 10, 2013 at 7:07

1 Answer 1

0

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...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .