0

I am using the below standard config to block download of hidden files from nginx :

#Prevent (deny) Access to Hidden Files with Nginx
    location ~ /\. {
            access_log off;
            log_not_found off; 
            deny all;
        }

But this config is also blocking genuine requests like :

2013/10/09 17:24:46 [error] 20121#0: *593378 access forbidden by rule, client: XX.55.XXX.201, server: XYZ.org, request: "GET /vip/validate.php?id=dfddfQ&title=.Mytitle HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock", host: "xyz.org"
iTech
  • 355
  • 4
  • 15
  • How are you sure that that is the rule being matched? – Michael Hampton Oct 10 '13 at 04:49
  • The error appears only when the "Title" parameter in query contains a DOT in the beginning. Also, there is no other rule in config which DENY's requests - am I missing something else here? – iTech Oct 10 '13 at 06:05
  • Your rule only matches a slash followed by a dot, so your title=.Mytitle param will not be matched. Try commenting off your rule, something else is preventing access. – Stephan Burlot Oct 12 '13 at 11:30

1 Answers1

1

You can debug which location from you nginx config applied to your request by adding "debug" to error.log:

error_log /path-to/error.log debug;

2015/09/24 16:22:12 [debug] 16458#0: *1539 http script copy: "/static.php"  
2015/09/24 16:22:12 [debug] 16458#0: *1539 http script args  
2015/09/24 16:22:12 [debug] 16458#0: *1539 http script copy: "resource="  
2015/09/24 16:22:12 [debug] 16458#0: *1539 http script capture: "frontend/Magento/luma/en_US/mage/calendar.css"  
2015/09/24 16:22:12 [debug] 16458#0: *1539 http script regex end  
2015/09/24 16:22:12 [debug] 16458#0: *1539 test location: "/"  
2015/09/24 16:22:12 [debug] 16458#0: *1539 test location: "pub"  
2015/09/24 16:22:12 [debug] 16458#0: *1539 test location: "static/"  
2015/09/24 16:22:12 [debug] 16458#0: *1539 test location: "setup"  
2015/09/24 16:22:12 [debug] 16458#0: *1539 test location: ~ "/\."  
2015/09/24 16:22:12 [debug] 16458#0: *1539 test location: ~ "/media/theme_customization/.*\.xml$"  
2015/09/24 16:22:12 [debug] 16458#0: *1539 test location: ~ "^/errors/.*\.(xml|phtml)$"  
2015/09/24 16:22:12 [debug] 16458#0: *1539 test location: ~ "cron\.php"  
2015/09/24 16:22:12 [debug] 16458#0: *1539 test location: ~ "\.php$"  
**2015/09/24 16:22:12 [debug] 16458#0: *1539 using configuration "\.php$"**  
Falcon Momot
  • 25,244
  • 15
  • 63
  • 92
Alexey P.
  • 11
  • 1