Nginx location issue
        Posted  
        
            by 
                dave
            
        on Server Fault
        
        See other posts from Server Fault
        
            or by dave
        
        
        
        Published on 2011-06-21T20:35:08Z
        Indexed on 
            2011/06/23
            0:24 UTC
        
        
        Read the original article
        Hit count: 613
        
I'm trying to set a longer (30 day) 'expires' header for my (images only) in the /misc-stuff/ directory.
This is what I'm using for my site :
# Serve static files directly from nginx
location ~* \.(jpg|jpeg|gif|png|bmp|ico|pdf|flv|swf|exe|html|htm|txt|css|js) {
   add_header        Cache-Control public;
   add_header        Cache-Control must-revalidate;
   expires           7d;
}
I want to be able to keep that code in to handle regular site images, but create a new block to handle the /misc-stuff/ directory.
I have tried :
location ^~ /misc-stuff/ {
...
}
The problem I'm having now is that my backup .php files in that directory show up as plain text if someone tries to access it.
How do I set it up so ONLY .gif images in the /misc-stuff/ directory are effected?
© Server Fault or respective owner