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

I'm serving up a static site via nginx.

    location ~* \.(avi|bin|bmp|dmg|doc|docx|dpkg|exe|flv|gif|htm|html|ico|ics|img|jpeg|jpg|m2a|m2v|mov|mp3|mp4|mpeg|mpg|msi|pdf|pkg|png|ppt|pptx|ps|rar|rss|rtf|swf|tif|tiff|txt|wmv|xhtml|xls|xml|zip)$ {
        root /var/www/html1;
        access_log off;
        expires 1d;
    }

And my goal is to exclude requests like http://connect1.webinar.ru/converter/task/. Full view is like http://mydomain.tld/converter/task/setComplete/fid/34330/fn/7c2cfed32ec2eef6788e728fa46f7a80.ppt.swf. Despite the fact these URLs ends in such a format they are not static, but fake script requests, so I have a problems with them.

What is the best way to do this? How can I add an exclusion for this URL or maybe I can to exclude the specific file exptension (.ppt.swf, pptx.swf) from the list of this Nginx location?

Thanks.

share|improve this question
    
Ou, and I forgot to add that the problem is that we have .swf format goes via Nginx. I need to exclude .ppt.swf, pptx.swf and same ext's only. I don't need to exclude .swf as a whole. –  Evgeniy Yablokov Jul 9 '12 at 6:22

2 Answers 2

up vote 1 down vote accepted
location ~* \.(?:avi|bin|bmp| ... |(?<!\.pptx\.|\.ppt\.)swf)$ {
    root /var/www/html1;
    access_log off;
    expires 1d;
}

.

$ man pcrepattern
$ man pcresyntax
share|improve this answer
    
Thank you very much. –  Evgeniy Yablokov Jul 9 '12 at 13:25

Since you're using regular expression in your location for static files, you can just add !pptx?\.swf condition to it and exclude condition swf

Your location will look like this:

location ~* \.(avi|bin|bmp| ... |!pptx?\.swf)$ {
        root /var/www/html1;
        access_log off;
        expires 1d;
}

And don't forget to add separate location for *.swf files:

location ~* [0-9a-z]*\.swf$
        root /var/www/html1;
        access_log off;
        expires 1d;
}
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.