Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
    
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 '13 at 10:26
    
yes, both locations are aliased to the same file... so the permission should be the same... –  user2780657 Oct 7 '13 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 '13 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... –  user2780657 Oct 8 '13 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 '13 at 7:07

1 Answer 1

up vote 0 down vote accepted

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.